diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json b/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json index 0d946ea03595..054d8a8ab7be 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json +++ b/sdk/containerregistry/azure-mgmt-containerregistry/_meta.json @@ -1,12 +1,12 @@ { - "commit": "e6bf6e8f8ff8b3325aa2618b712d5c3bad770631", + "commit": "c65154bfd74987c8be8415d43123fb16529bc14d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.10.2", "use": [ - "@autorest/python@6.26.4", + "@autorest/python@6.27.4", "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/containerregistry/resource-manager/readme.md --generate-sample=True --generate-test=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.26.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", + "autorest_command": "autorest specification/containerregistry/resource-manager/readme.md --generate-sample=True --generate-test=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.27.4 --use=@autorest/modelerfour@4.27.0 --version=3.10.2 --version-tolerant=False", "readme": "specification/containerregistry/resource-manager/readme.md", "package-2023-08-preview-only": "2023-08-29 18:41:57 -0700 3e3098d6b9302e166b611ce72b3392786d3ea0f7 Microsoft.ContainerRegistry/preview/2023-08-01-preview/containerregistry.json", "package-2023-07-only": "2023-08-16 14:55:49 -0700 d5631d7fbffb672434457b5f2f16cdc6691356f9 Microsoft.ContainerRegistry/stable/2023-07-01/containerregistry.json", 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 8e1f0b09f979..e914966ba971 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_configuration.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_configuration.py @@ -27,7 +27,7 @@ class ContainerRegistryManagementClientConfiguration: :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. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str """ 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 3101a563909a..df0370a492c5 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 @@ -45,7 +45,7 @@ class ContainerRegistryManagementClient(MultiApiClientMixin, _SDKClient): :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. + :param subscription_id: The Microsoft Azure subscription ID. 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,15 +56,11 @@ 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 = '2023-07-01' + DEFAULT_API_VERSION = '2019-05-01' _PROFILE_TAG = "azure.mgmt.containerregistry.ContainerRegistryManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, - 'agent_pools': '2019-06-01-preview', - 'runs': '2019-04-01', - 'task_runs': '2019-06-01-preview', - 'tasks': '2019-04-01', }}, _PROFILE_TAG + " latest" ) @@ -99,7 +95,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(ContainerRegistryManagementClient, self).__init__( api_version=api_version, profile=profile @@ -113,41 +109,17 @@ def _models_dict(cls, api_version): def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: - * 2017-03-01: :mod:`v2017_03_01.models` - * 2017-10-01: :mod:`v2017_10_01.models` - * 2018-09-01: :mod:`v2018_09_01.models` - * 2019-04-01: :mod:`v2019_04_01.models` * 2019-05-01: :mod:`v2019_05_01.models` * 2019-05-01-preview: :mod:`v2019_05_01_preview.models` * 2019-06-01-preview: :mod:`v2019_06_01_preview.models` - * 2019-12-01-preview: :mod:`v2019_12_01_preview.models` * 2020-11-01-preview: :mod:`v2020_11_01_preview.models` - * 2021-06-01-preview: :mod:`v2021_06_01_preview.models` * 2021-08-01-preview: :mod:`v2021_08_01_preview.models` - * 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` - * 2023-06-01-preview: :mod:`v2023_06_01_preview.models` - * 2023-07-01: :mod:`v2023_07_01.models` - * 2023-08-01-preview: :mod:`v2023_08_01_preview.models` * 2023-11-01-preview: :mod:`v2023_11_01_preview.models` * 2024-11-01-preview: :mod:`v2024_11_01_preview.models` """ - if api_version == '2017-03-01': - from .v2017_03_01 import models - return models - elif api_version == '2017-10-01': - from .v2017_10_01 import models - return models - elif api_version == '2018-09-01': - from .v2018_09_01 import models - return models - elif api_version == '2019-04-01': - from .v2019_04_01 import models - return models - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from .v2019_05_01 import models return models elif api_version == '2019-05-01-preview': @@ -156,42 +128,18 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2019-06-01-preview': from .v2019_06_01_preview import models return models - elif api_version == '2019-12-01-preview': - from .v2019_12_01_preview import models - return models elif api_version == '2020-11-01-preview': from .v2020_11_01_preview import models return models - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview import models - return models elif api_version == '2021-08-01-preview': from .v2021_08_01_preview import models return models - elif api_version == '2021-09-01': - from .v2021_09_01 import models - return models - elif api_version == '2021-12-01-preview': - from .v2021_12_01_preview import models - return models 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview import models - return models - elif api_version == '2023-07-01': - from .v2023_07_01 import models - return models - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview import models - return models elif api_version == '2023-11-01-preview': from .v2023_11_01_preview import models return models @@ -218,17 +166,11 @@ def agent_pools(self): def archive_versions(self): """Instance depends on the API version: - * 2023-06-01-preview: :class:`ArchiveVersionsOperations` - * 2023-08-01-preview: :class:`ArchiveVersionsOperations` * 2023-11-01-preview: :class:`ArchiveVersionsOperations` * 2024-11-01-preview: :class:`ArchiveVersionsOperations` """ api_version = self._get_api_version('archive_versions') - if api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import ArchiveVersionsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import ArchiveVersionsOperations as OperationClass - elif api_version == '2023-11-01-preview': + if api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import ArchiveVersionsOperations as OperationClass elif api_version == '2024-11-01-preview': from .v2024_11_01_preview.operations import ArchiveVersionsOperations as OperationClass @@ -241,17 +183,11 @@ def archive_versions(self): def archives(self): """Instance depends on the API version: - * 2023-06-01-preview: :class:`ArchivesOperations` - * 2023-08-01-preview: :class:`ArchivesOperations` * 2023-11-01-preview: :class:`ArchivesOperations` * 2024-11-01-preview: :class:`ArchivesOperations` """ api_version = self._get_api_version('archives') - if api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import ArchivesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import ArchivesOperations as OperationClass - elif api_version == '2023-11-01-preview': + if api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import ArchivesOperations as OperationClass elif api_version == '2024-11-01-preview': from .v2024_11_01_preview.operations import ArchivesOperations as OperationClass @@ -265,21 +201,12 @@ def cache_rules(self): """Instance depends on the API version: * 2023-01-01-preview: :class:`CacheRulesOperations` - * 2023-06-01-preview: :class:`CacheRulesOperations` - * 2023-07-01: :class:`CacheRulesOperations` - * 2023-08-01-preview: :class:`CacheRulesOperations` * 2023-11-01-preview: :class:`CacheRulesOperations` * 2024-11-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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import CacheRulesOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import CacheRulesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import CacheRulesOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import CacheRulesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -294,33 +221,21 @@ def connected_registries(self): """Instance depends on the API version: * 2020-11-01-preview: :class:`ConnectedRegistriesOperations` - * 2021-06-01-preview: :class:`ConnectedRegistriesOperations` * 2021-08-01-preview: :class:`ConnectedRegistriesOperations` - * 2021-12-01-preview: :class:`ConnectedRegistriesOperations` * 2022-02-01-preview: :class:`ConnectedRegistriesOperations` * 2023-01-01-preview: :class:`ConnectedRegistriesOperations` - * 2023-06-01-preview: :class:`ConnectedRegistriesOperations` - * 2023-08-01-preview: :class:`ConnectedRegistriesOperations` * 2023-11-01-preview: :class:`ConnectedRegistriesOperations` * 2024-11-01-preview: :class:`ConnectedRegistriesOperations` """ api_version = self._get_api_version('connected_registries') if api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import ConnectedRegistriesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import ConnectedRegistriesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import ConnectedRegistriesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -335,21 +250,12 @@ def credential_sets(self): """Instance depends on the API version: * 2023-01-01-preview: :class:`CredentialSetsOperations` - * 2023-06-01-preview: :class:`CredentialSetsOperations` - * 2023-07-01: :class:`CredentialSetsOperations` - * 2023-08-01-preview: :class:`CredentialSetsOperations` * 2023-11-01-preview: :class:`CredentialSetsOperations` * 2024-11-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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import CredentialSetsOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import CredentialSetsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import CredentialSetsOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import CredentialSetsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -363,37 +269,22 @@ def credential_sets(self): def export_pipelines(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`ExportPipelinesOperations` * 2020-11-01-preview: :class:`ExportPipelinesOperations` - * 2021-06-01-preview: :class:`ExportPipelinesOperations` * 2021-08-01-preview: :class:`ExportPipelinesOperations` - * 2021-12-01-preview: :class:`ExportPipelinesOperations` * 2022-02-01-preview: :class:`ExportPipelinesOperations` * 2023-01-01-preview: :class:`ExportPipelinesOperations` - * 2023-06-01-preview: :class:`ExportPipelinesOperations` - * 2023-08-01-preview: :class:`ExportPipelinesOperations` * 2023-11-01-preview: :class:`ExportPipelinesOperations` * 2024-11-01-preview: :class:`ExportPipelinesOperations` """ api_version = self._get_api_version('export_pipelines') - if api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import ExportPipelinesOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import ExportPipelinesOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import ExportPipelinesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -407,37 +298,22 @@ def export_pipelines(self): def import_pipelines(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`ImportPipelinesOperations` * 2020-11-01-preview: :class:`ImportPipelinesOperations` - * 2021-06-01-preview: :class:`ImportPipelinesOperations` * 2021-08-01-preview: :class:`ImportPipelinesOperations` - * 2021-12-01-preview: :class:`ImportPipelinesOperations` * 2022-02-01-preview: :class:`ImportPipelinesOperations` * 2023-01-01-preview: :class:`ImportPipelinesOperations` - * 2023-06-01-preview: :class:`ImportPipelinesOperations` - * 2023-08-01-preview: :class:`ImportPipelinesOperations` * 2023-11-01-preview: :class:`ImportPipelinesOperations` * 2024-11-01-preview: :class:`ImportPipelinesOperations` """ api_version = self._get_api_version('import_pipelines') - if api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import ImportPipelinesOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import ImportPipelinesOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import ImportPipelinesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -451,55 +327,25 @@ def import_pipelines(self): def operations(self): """Instance depends on the API version: - * 2017-03-01: :class:`Operations` - * 2017-10-01: :class:`Operations` * 2019-05-01: :class:`Operations` - * 2019-12-01-preview: :class:`Operations` * 2020-11-01-preview: :class:`Operations` - * 2021-06-01-preview: :class:`Operations` * 2021-08-01-preview: :class:`Operations` - * 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` - * 2023-06-01-preview: :class:`Operations` - * 2023-07-01: :class:`Operations` - * 2023-08-01-preview: :class:`Operations` * 2023-11-01-preview: :class:`Operations` * 2024-11-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') - if api_version == '2017-03-01': - from .v2017_03_01.operations import Operations as OperationClass - elif api_version == '2017-10-01': - from .v2017_10_01.operations import Operations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from .v2019_05_01.operations import Operations as OperationClass - elif api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import Operations as OperationClass elif api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import Operations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import Operations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import Operations as OperationClass - elif api_version == '2021-09-01': - from .v2021_09_01.operations import Operations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import Operations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import Operations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import Operations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import Operations as OperationClass elif api_version == '2024-11-01-preview': @@ -513,37 +359,22 @@ def operations(self): def pipeline_runs(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`PipelineRunsOperations` * 2020-11-01-preview: :class:`PipelineRunsOperations` - * 2021-06-01-preview: :class:`PipelineRunsOperations` * 2021-08-01-preview: :class:`PipelineRunsOperations` - * 2021-12-01-preview: :class:`PipelineRunsOperations` * 2022-02-01-preview: :class:`PipelineRunsOperations` * 2023-01-01-preview: :class:`PipelineRunsOperations` - * 2023-06-01-preview: :class:`PipelineRunsOperations` - * 2023-08-01-preview: :class:`PipelineRunsOperations` * 2023-11-01-preview: :class:`PipelineRunsOperations` * 2024-11-01-preview: :class:`PipelineRunsOperations` """ api_version = self._get_api_version('pipeline_runs') - if api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import PipelineRunsOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import PipelineRunsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import PipelineRunsOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import PipelineRunsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import PipelineRunsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import PipelineRunsOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import PipelineRunsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -557,46 +388,22 @@ def pipeline_runs(self): def private_endpoint_connections(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2020-11-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 2021-06-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2021-08-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 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` - * 2023-06-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 2023-07-01: :class:`PrivateEndpointConnectionsOperations` - * 2023-08-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2023-11-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2024-11-01-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') - if api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-09-01': - from .v2021_09_01.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -610,67 +417,31 @@ def private_endpoint_connections(self): def registries(self): """Instance depends on the API version: - * 2017-03-01: :class:`RegistriesOperations` - * 2017-10-01: :class:`RegistriesOperations` - * 2018-09-01: :class:`RegistriesOperations` - * 2019-04-01: :class:`RegistriesOperations` * 2019-05-01: :class:`RegistriesOperations` * 2019-05-01-preview: :class:`RegistriesOperations` * 2019-06-01-preview: :class:`RegistriesOperations` - * 2019-12-01-preview: :class:`RegistriesOperations` * 2020-11-01-preview: :class:`RegistriesOperations` - * 2021-06-01-preview: :class:`RegistriesOperations` * 2021-08-01-preview: :class:`RegistriesOperations` - * 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` - * 2023-06-01-preview: :class:`RegistriesOperations` - * 2023-07-01: :class:`RegistriesOperations` - * 2023-08-01-preview: :class:`RegistriesOperations` * 2023-11-01-preview: :class:`RegistriesOperations` * 2024-11-01-preview: :class:`RegistriesOperations` """ api_version = self._get_api_version('registries') - if api_version == '2017-03-01': - from .v2017_03_01.operations import RegistriesOperations as OperationClass - elif api_version == '2017-10-01': - from .v2017_10_01.operations import RegistriesOperations as OperationClass - elif api_version == '2018-09-01': - from .v2018_09_01.operations import RegistriesOperations as OperationClass - elif api_version == '2019-04-01': - from .v2019_04_01.operations import RegistriesOperations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from .v2019_05_01.operations import RegistriesOperations as OperationClass elif api_version == '2019-05-01-preview': from .v2019_05_01_preview.operations import RegistriesOperations as OperationClass elif api_version == '2019-06-01-preview': from .v2019_06_01_preview.operations import RegistriesOperations as OperationClass - elif api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import RegistriesOperations as OperationClass elif api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import RegistriesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import RegistriesOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import RegistriesOperations as OperationClass - elif api_version == '2021-09-01': - from .v2021_09_01.operations import RegistriesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import RegistriesOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import RegistriesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import RegistriesOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import RegistriesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -684,52 +455,25 @@ def registries(self): def replications(self): """Instance depends on the API version: - * 2017-10-01: :class:`ReplicationsOperations` * 2019-05-01: :class:`ReplicationsOperations` - * 2019-12-01-preview: :class:`ReplicationsOperations` * 2020-11-01-preview: :class:`ReplicationsOperations` - * 2021-06-01-preview: :class:`ReplicationsOperations` * 2021-08-01-preview: :class:`ReplicationsOperations` - * 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` - * 2023-06-01-preview: :class:`ReplicationsOperations` - * 2023-07-01: :class:`ReplicationsOperations` - * 2023-08-01-preview: :class:`ReplicationsOperations` * 2023-11-01-preview: :class:`ReplicationsOperations` * 2024-11-01-preview: :class:`ReplicationsOperations` """ api_version = self._get_api_version('replications') - if api_version == '2017-10-01': - from .v2017_10_01.operations import ReplicationsOperations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from .v2019_05_01.operations import ReplicationsOperations as OperationClass - elif api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import ReplicationsOperations as OperationClass elif api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import ReplicationsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import ReplicationsOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import ReplicationsOperations as OperationClass - elif api_version == '2021-09-01': - from .v2021_09_01.operations import ReplicationsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import ReplicationsOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import ReplicationsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import ReplicationsOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import ReplicationsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -743,16 +487,10 @@ def replications(self): def runs(self): """Instance depends on the API version: - * 2018-09-01: :class:`RunsOperations` - * 2019-04-01: :class:`RunsOperations` * 2019-06-01-preview: :class:`RunsOperations` """ api_version = self._get_api_version('runs') - if api_version == '2018-09-01': - from .v2018_09_01.operations import RunsOperations as OperationClass - elif api_version == '2019-04-01': - from .v2019_04_01.operations import RunsOperations as OperationClass - elif api_version == '2019-06-01-preview': + if api_version == '2019-06-01-preview': from .v2019_06_01_preview.operations import RunsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'runs'".format(api_version)) @@ -765,15 +503,9 @@ def scope_maps(self): * 2019-05-01-preview: :class:`ScopeMapsOperations` * 2020-11-01-preview: :class:`ScopeMapsOperations` - * 2021-06-01-preview: :class:`ScopeMapsOperations` * 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` - * 2023-06-01-preview: :class:`ScopeMapsOperations` - * 2023-07-01: :class:`ScopeMapsOperations` - * 2023-08-01-preview: :class:`ScopeMapsOperations` * 2023-11-01-preview: :class:`ScopeMapsOperations` * 2024-11-01-preview: :class:`ScopeMapsOperations` """ @@ -782,24 +514,12 @@ def scope_maps(self): from .v2019_05_01_preview.operations import ScopeMapsOperations as OperationClass elif api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import ScopeMapsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import ScopeMapsOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import ScopeMapsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import ScopeMapsOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import ScopeMapsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import ScopeMapsOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import ScopeMapsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -827,16 +547,10 @@ def task_runs(self): def tasks(self): """Instance depends on the API version: - * 2018-09-01: :class:`TasksOperations` - * 2019-04-01: :class:`TasksOperations` * 2019-06-01-preview: :class:`TasksOperations` """ api_version = self._get_api_version('tasks') - if api_version == '2018-09-01': - from .v2018_09_01.operations import TasksOperations as OperationClass - elif api_version == '2019-04-01': - from .v2019_04_01.operations import TasksOperations as OperationClass - elif api_version == '2019-06-01-preview': + if api_version == '2019-06-01-preview': from .v2019_06_01_preview.operations import TasksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) @@ -849,15 +563,9 @@ def tokens(self): * 2019-05-01-preview: :class:`TokensOperations` * 2020-11-01-preview: :class:`TokensOperations` - * 2021-06-01-preview: :class:`TokensOperations` * 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` - * 2023-06-01-preview: :class:`TokensOperations` - * 2023-07-01: :class:`TokensOperations` - * 2023-08-01-preview: :class:`TokensOperations` * 2023-11-01-preview: :class:`TokensOperations` * 2024-11-01-preview: :class:`TokensOperations` """ @@ -866,24 +574,12 @@ def tokens(self): from .v2019_05_01_preview.operations import TokensOperations as OperationClass elif api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import TokensOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import TokensOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import TokensOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import TokensOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import TokensOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import TokensOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import TokensOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -897,52 +593,25 @@ def tokens(self): def webhooks(self): """Instance depends on the API version: - * 2017-10-01: :class:`WebhooksOperations` * 2019-05-01: :class:`WebhooksOperations` - * 2019-12-01-preview: :class:`WebhooksOperations` * 2020-11-01-preview: :class:`WebhooksOperations` - * 2021-06-01-preview: :class:`WebhooksOperations` * 2021-08-01-preview: :class:`WebhooksOperations` - * 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` - * 2023-06-01-preview: :class:`WebhooksOperations` - * 2023-07-01: :class:`WebhooksOperations` - * 2023-08-01-preview: :class:`WebhooksOperations` * 2023-11-01-preview: :class:`WebhooksOperations` * 2024-11-01-preview: :class:`WebhooksOperations` """ api_version = self._get_api_version('webhooks') - if api_version == '2017-10-01': - from .v2017_10_01.operations import WebhooksOperations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from .v2019_05_01.operations import WebhooksOperations as OperationClass - elif api_version == '2019-12-01-preview': - from .v2019_12_01_preview.operations import WebhooksOperations as OperationClass elif api_version == '2020-11-01-preview': from .v2020_11_01_preview.operations import WebhooksOperations as OperationClass - elif api_version == '2021-06-01-preview': - from .v2021_06_01_preview.operations import WebhooksOperations as OperationClass elif api_version == '2021-08-01-preview': from .v2021_08_01_preview.operations import WebhooksOperations as OperationClass - elif api_version == '2021-09-01': - from .v2021_09_01.operations import WebhooksOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from .v2023_06_01_preview.operations import WebhooksOperations as OperationClass - elif api_version == '2023-07-01': - from .v2023_07_01.operations import WebhooksOperations as OperationClass - elif api_version == '2023-08-01-preview': - from .v2023_08_01_preview.operations import WebhooksOperations as OperationClass elif api_version == '2023-11-01-preview': from .v2023_11_01_preview.operations import WebhooksOperations as OperationClass elif api_version == '2024-11-01-preview': diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_serialization.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_serialization.py index dc8692e6ec0f..a94487cbf17a 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_serialization.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/_serialization.py @@ -309,7 +309,7 @@ def _create_xml_node(tag, prefix=None, ns=None): return ET.Element(tag) -class Model(object): +class Model: """Mixin for all client request body/response body models to support serialization and deserialization. """ @@ -562,7 +562,7 @@ def _decode_attribute_map_key(key): return key.replace("\\.", ".") -class Serializer(object): # pylint: disable=too-many-public-methods +class Serializer: # pylint: disable=too-many-public-methods """Request object model serializer.""" basic_types = {str: "str", int: "int", bool: "bool", float: "float"} @@ -1440,7 +1440,7 @@ def xml_key_extractor(attr, attr_desc, data): # pylint: disable=unused-argument return children[0] -class Deserializer(object): +class Deserializer: """Response object model deserializer. :param dict classes: Class type dictionary for deserializing complex types. @@ -1682,17 +1682,21 @@ def _instantiate_model(self, response, attrs, additional_properties=None): subtype = getattr(response, "_subtype_map", {}) try: readonly = [ - k for k, v in response._validation.items() if v.get("readonly") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + if v.get("readonly") ] const = [ - k for k, v in response._validation.items() if v.get("constant") # pylint: disable=protected-access + k + for k, v in response._validation.items() # pylint: disable=protected-access # type: ignore + 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 + response_obj.additional_properties = additional_properties # type: ignore return response_obj except TypeError as err: msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore 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 0de17c25d4c1..cba9fef95a4b 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 @@ -27,7 +27,7 @@ class ContainerRegistryManagementClientConfiguration: :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. + :param subscription_id: The Microsoft Azure subscription ID. Required. :type subscription_id: str """ 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 25729f7b3edd..c02f68a83254 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 @@ -45,7 +45,7 @@ class ContainerRegistryManagementClient(MultiApiClientMixin, _SDKClient): :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. + :param subscription_id: The Microsoft Azure subscription ID. 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,15 +56,11 @@ 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 = '2023-07-01' + DEFAULT_API_VERSION = '2019-05-01' _PROFILE_TAG = "azure.mgmt.containerregistry.ContainerRegistryManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { None: DEFAULT_API_VERSION, - 'agent_pools': '2019-06-01-preview', - 'runs': '2019-04-01', - 'task_runs': '2019-06-01-preview', - 'tasks': '2019-04-01', }}, _PROFILE_TAG + " latest" ) @@ -99,7 +95,7 @@ def __init__( policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, self._config.http_logging_policy, ] - self._client = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) super(ContainerRegistryManagementClient, self).__init__( api_version=api_version, profile=profile @@ -113,41 +109,17 @@ def _models_dict(cls, api_version): def models(cls, api_version=DEFAULT_API_VERSION): """Module depends on the API version: - * 2017-03-01: :mod:`v2017_03_01.models` - * 2017-10-01: :mod:`v2017_10_01.models` - * 2018-09-01: :mod:`v2018_09_01.models` - * 2019-04-01: :mod:`v2019_04_01.models` * 2019-05-01: :mod:`v2019_05_01.models` * 2019-05-01-preview: :mod:`v2019_05_01_preview.models` * 2019-06-01-preview: :mod:`v2019_06_01_preview.models` - * 2019-12-01-preview: :mod:`v2019_12_01_preview.models` * 2020-11-01-preview: :mod:`v2020_11_01_preview.models` - * 2021-06-01-preview: :mod:`v2021_06_01_preview.models` * 2021-08-01-preview: :mod:`v2021_08_01_preview.models` - * 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` - * 2023-06-01-preview: :mod:`v2023_06_01_preview.models` - * 2023-07-01: :mod:`v2023_07_01.models` - * 2023-08-01-preview: :mod:`v2023_08_01_preview.models` * 2023-11-01-preview: :mod:`v2023_11_01_preview.models` * 2024-11-01-preview: :mod:`v2024_11_01_preview.models` """ - if api_version == '2017-03-01': - from ..v2017_03_01 import models - return models - elif api_version == '2017-10-01': - from ..v2017_10_01 import models - return models - elif api_version == '2018-09-01': - from ..v2018_09_01 import models - return models - elif api_version == '2019-04-01': - from ..v2019_04_01 import models - return models - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from ..v2019_05_01 import models return models elif api_version == '2019-05-01-preview': @@ -156,42 +128,18 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2019-06-01-preview': from ..v2019_06_01_preview import models return models - elif api_version == '2019-12-01-preview': - from ..v2019_12_01_preview import models - return models elif api_version == '2020-11-01-preview': from ..v2020_11_01_preview import models return models - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview import models - return models elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview import models return models - elif api_version == '2021-09-01': - from ..v2021_09_01 import models - return models - elif api_version == '2021-12-01-preview': - from ..v2021_12_01_preview import models - return models 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview import models - return models - elif api_version == '2023-07-01': - from ..v2023_07_01 import models - return models - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview import models - return models elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview import models return models @@ -218,17 +166,11 @@ def agent_pools(self): def archive_versions(self): """Instance depends on the API version: - * 2023-06-01-preview: :class:`ArchiveVersionsOperations` - * 2023-08-01-preview: :class:`ArchiveVersionsOperations` * 2023-11-01-preview: :class:`ArchiveVersionsOperations` * 2024-11-01-preview: :class:`ArchiveVersionsOperations` """ api_version = self._get_api_version('archive_versions') - if api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import ArchiveVersionsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import ArchiveVersionsOperations as OperationClass - elif api_version == '2023-11-01-preview': + if api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import ArchiveVersionsOperations as OperationClass elif api_version == '2024-11-01-preview': from ..v2024_11_01_preview.aio.operations import ArchiveVersionsOperations as OperationClass @@ -241,17 +183,11 @@ def archive_versions(self): def archives(self): """Instance depends on the API version: - * 2023-06-01-preview: :class:`ArchivesOperations` - * 2023-08-01-preview: :class:`ArchivesOperations` * 2023-11-01-preview: :class:`ArchivesOperations` * 2024-11-01-preview: :class:`ArchivesOperations` """ api_version = self._get_api_version('archives') - if api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import ArchivesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import ArchivesOperations as OperationClass - elif api_version == '2023-11-01-preview': + if api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import ArchivesOperations as OperationClass elif api_version == '2024-11-01-preview': from ..v2024_11_01_preview.aio.operations import ArchivesOperations as OperationClass @@ -265,21 +201,12 @@ def cache_rules(self): """Instance depends on the API version: * 2023-01-01-preview: :class:`CacheRulesOperations` - * 2023-06-01-preview: :class:`CacheRulesOperations` - * 2023-07-01: :class:`CacheRulesOperations` - * 2023-08-01-preview: :class:`CacheRulesOperations` * 2023-11-01-preview: :class:`CacheRulesOperations` * 2024-11-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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import CacheRulesOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import CacheRulesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import CacheRulesOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import CacheRulesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -294,33 +221,21 @@ def connected_registries(self): """Instance depends on the API version: * 2020-11-01-preview: :class:`ConnectedRegistriesOperations` - * 2021-06-01-preview: :class:`ConnectedRegistriesOperations` * 2021-08-01-preview: :class:`ConnectedRegistriesOperations` - * 2021-12-01-preview: :class:`ConnectedRegistriesOperations` * 2022-02-01-preview: :class:`ConnectedRegistriesOperations` * 2023-01-01-preview: :class:`ConnectedRegistriesOperations` - * 2023-06-01-preview: :class:`ConnectedRegistriesOperations` - * 2023-08-01-preview: :class:`ConnectedRegistriesOperations` * 2023-11-01-preview: :class:`ConnectedRegistriesOperations` * 2024-11-01-preview: :class:`ConnectedRegistriesOperations` """ api_version = self._get_api_version('connected_registries') if api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import ConnectedRegistriesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -335,21 +250,12 @@ def credential_sets(self): """Instance depends on the API version: * 2023-01-01-preview: :class:`CredentialSetsOperations` - * 2023-06-01-preview: :class:`CredentialSetsOperations` - * 2023-07-01: :class:`CredentialSetsOperations` - * 2023-08-01-preview: :class:`CredentialSetsOperations` * 2023-11-01-preview: :class:`CredentialSetsOperations` * 2024-11-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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import CredentialSetsOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import CredentialSetsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import CredentialSetsOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import CredentialSetsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -363,37 +269,22 @@ def credential_sets(self): def export_pipelines(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`ExportPipelinesOperations` * 2020-11-01-preview: :class:`ExportPipelinesOperations` - * 2021-06-01-preview: :class:`ExportPipelinesOperations` * 2021-08-01-preview: :class:`ExportPipelinesOperations` - * 2021-12-01-preview: :class:`ExportPipelinesOperations` * 2022-02-01-preview: :class:`ExportPipelinesOperations` * 2023-01-01-preview: :class:`ExportPipelinesOperations` - * 2023-06-01-preview: :class:`ExportPipelinesOperations` - * 2023-08-01-preview: :class:`ExportPipelinesOperations` * 2023-11-01-preview: :class:`ExportPipelinesOperations` * 2024-11-01-preview: :class:`ExportPipelinesOperations` """ api_version = self._get_api_version('export_pipelines') - if api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import ExportPipelinesOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import ExportPipelinesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import ExportPipelinesOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import ExportPipelinesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -407,37 +298,22 @@ def export_pipelines(self): def import_pipelines(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`ImportPipelinesOperations` * 2020-11-01-preview: :class:`ImportPipelinesOperations` - * 2021-06-01-preview: :class:`ImportPipelinesOperations` * 2021-08-01-preview: :class:`ImportPipelinesOperations` - * 2021-12-01-preview: :class:`ImportPipelinesOperations` * 2022-02-01-preview: :class:`ImportPipelinesOperations` * 2023-01-01-preview: :class:`ImportPipelinesOperations` - * 2023-06-01-preview: :class:`ImportPipelinesOperations` - * 2023-08-01-preview: :class:`ImportPipelinesOperations` * 2023-11-01-preview: :class:`ImportPipelinesOperations` * 2024-11-01-preview: :class:`ImportPipelinesOperations` """ api_version = self._get_api_version('import_pipelines') - if api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import ImportPipelinesOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import ImportPipelinesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import ImportPipelinesOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import ImportPipelinesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -451,55 +327,25 @@ def import_pipelines(self): def operations(self): """Instance depends on the API version: - * 2017-03-01: :class:`Operations` - * 2017-10-01: :class:`Operations` * 2019-05-01: :class:`Operations` - * 2019-12-01-preview: :class:`Operations` * 2020-11-01-preview: :class:`Operations` - * 2021-06-01-preview: :class:`Operations` * 2021-08-01-preview: :class:`Operations` - * 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` - * 2023-06-01-preview: :class:`Operations` - * 2023-07-01: :class:`Operations` - * 2023-08-01-preview: :class:`Operations` * 2023-11-01-preview: :class:`Operations` * 2024-11-01-preview: :class:`Operations` """ api_version = self._get_api_version('operations') - if api_version == '2017-03-01': - from ..v2017_03_01.aio.operations import Operations as OperationClass - elif api_version == '2017-10-01': - from ..v2017_10_01.aio.operations import Operations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from ..v2019_05_01.aio.operations import Operations as OperationClass - elif api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import Operations as OperationClass elif api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import Operations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2021-09-01': - from ..v2021_09_01.aio.operations import Operations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import Operations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import Operations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import Operations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import Operations as OperationClass elif api_version == '2024-11-01-preview': @@ -513,37 +359,22 @@ def operations(self): def pipeline_runs(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`PipelineRunsOperations` * 2020-11-01-preview: :class:`PipelineRunsOperations` - * 2021-06-01-preview: :class:`PipelineRunsOperations` * 2021-08-01-preview: :class:`PipelineRunsOperations` - * 2021-12-01-preview: :class:`PipelineRunsOperations` * 2022-02-01-preview: :class:`PipelineRunsOperations` * 2023-01-01-preview: :class:`PipelineRunsOperations` - * 2023-06-01-preview: :class:`PipelineRunsOperations` - * 2023-08-01-preview: :class:`PipelineRunsOperations` * 2023-11-01-preview: :class:`PipelineRunsOperations` * 2024-11-01-preview: :class:`PipelineRunsOperations` """ api_version = self._get_api_version('pipeline_runs') - if api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import PipelineRunsOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import PipelineRunsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import PipelineRunsOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import PipelineRunsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import PipelineRunsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import PipelineRunsOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import PipelineRunsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -557,46 +388,22 @@ def pipeline_runs(self): def private_endpoint_connections(self): """Instance depends on the API version: - * 2019-12-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2020-11-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 2021-06-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2021-08-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 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` - * 2023-06-01-preview: :class:`PrivateEndpointConnectionsOperations` - * 2023-07-01: :class:`PrivateEndpointConnectionsOperations` - * 2023-08-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2023-11-01-preview: :class:`PrivateEndpointConnectionsOperations` * 2024-11-01-preview: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') - if api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2020-11-01-preview': + if api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-09-01': - from ..v2021_09_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -610,67 +417,31 @@ def private_endpoint_connections(self): def registries(self): """Instance depends on the API version: - * 2017-03-01: :class:`RegistriesOperations` - * 2017-10-01: :class:`RegistriesOperations` - * 2018-09-01: :class:`RegistriesOperations` - * 2019-04-01: :class:`RegistriesOperations` * 2019-05-01: :class:`RegistriesOperations` * 2019-05-01-preview: :class:`RegistriesOperations` * 2019-06-01-preview: :class:`RegistriesOperations` - * 2019-12-01-preview: :class:`RegistriesOperations` * 2020-11-01-preview: :class:`RegistriesOperations` - * 2021-06-01-preview: :class:`RegistriesOperations` * 2021-08-01-preview: :class:`RegistriesOperations` - * 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` - * 2023-06-01-preview: :class:`RegistriesOperations` - * 2023-07-01: :class:`RegistriesOperations` - * 2023-08-01-preview: :class:`RegistriesOperations` * 2023-11-01-preview: :class:`RegistriesOperations` * 2024-11-01-preview: :class:`RegistriesOperations` """ api_version = self._get_api_version('registries') - if api_version == '2017-03-01': - from ..v2017_03_01.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2017-10-01': - from ..v2017_10_01.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2018-09-01': - from ..v2018_09_01.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2019-04-01': - from ..v2019_04_01.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from ..v2019_05_01.aio.operations import RegistriesOperations as OperationClass elif api_version == '2019-05-01-preview': from ..v2019_05_01_preview.aio.operations import RegistriesOperations as OperationClass elif api_version == '2019-06-01-preview': from ..v2019_06_01_preview.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import RegistriesOperations as OperationClass elif api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import RegistriesOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2021-09-01': - from ..v2021_09_01.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import RegistriesOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import RegistriesOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import RegistriesOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -684,52 +455,25 @@ def registries(self): def replications(self): """Instance depends on the API version: - * 2017-10-01: :class:`ReplicationsOperations` * 2019-05-01: :class:`ReplicationsOperations` - * 2019-12-01-preview: :class:`ReplicationsOperations` * 2020-11-01-preview: :class:`ReplicationsOperations` - * 2021-06-01-preview: :class:`ReplicationsOperations` * 2021-08-01-preview: :class:`ReplicationsOperations` - * 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` - * 2023-06-01-preview: :class:`ReplicationsOperations` - * 2023-07-01: :class:`ReplicationsOperations` - * 2023-08-01-preview: :class:`ReplicationsOperations` * 2023-11-01-preview: :class:`ReplicationsOperations` * 2024-11-01-preview: :class:`ReplicationsOperations` """ api_version = self._get_api_version('replications') - if api_version == '2017-10-01': - from ..v2017_10_01.aio.operations import ReplicationsOperations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from ..v2019_05_01.aio.operations import ReplicationsOperations as OperationClass - elif api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import ReplicationsOperations as OperationClass elif api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import ReplicationsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import ReplicationsOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import ReplicationsOperations as OperationClass - elif api_version == '2021-09-01': - from ..v2021_09_01.aio.operations import ReplicationsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import ReplicationsOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import ReplicationsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import ReplicationsOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import ReplicationsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -743,16 +487,10 @@ def replications(self): def runs(self): """Instance depends on the API version: - * 2018-09-01: :class:`RunsOperations` - * 2019-04-01: :class:`RunsOperations` * 2019-06-01-preview: :class:`RunsOperations` """ api_version = self._get_api_version('runs') - if api_version == '2018-09-01': - from ..v2018_09_01.aio.operations import RunsOperations as OperationClass - elif api_version == '2019-04-01': - from ..v2019_04_01.aio.operations import RunsOperations as OperationClass - elif api_version == '2019-06-01-preview': + if api_version == '2019-06-01-preview': 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)) @@ -765,15 +503,9 @@ def scope_maps(self): * 2019-05-01-preview: :class:`ScopeMapsOperations` * 2020-11-01-preview: :class:`ScopeMapsOperations` - * 2021-06-01-preview: :class:`ScopeMapsOperations` * 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` - * 2023-06-01-preview: :class:`ScopeMapsOperations` - * 2023-07-01: :class:`ScopeMapsOperations` - * 2023-08-01-preview: :class:`ScopeMapsOperations` * 2023-11-01-preview: :class:`ScopeMapsOperations` * 2024-11-01-preview: :class:`ScopeMapsOperations` """ @@ -782,24 +514,12 @@ def scope_maps(self): from ..v2019_05_01_preview.aio.operations import ScopeMapsOperations as OperationClass elif api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import ScopeMapsOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import ScopeMapsOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import ScopeMapsOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import ScopeMapsOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import ScopeMapsOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import ScopeMapsOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import ScopeMapsOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -827,16 +547,10 @@ def task_runs(self): def tasks(self): """Instance depends on the API version: - * 2018-09-01: :class:`TasksOperations` - * 2019-04-01: :class:`TasksOperations` * 2019-06-01-preview: :class:`TasksOperations` """ api_version = self._get_api_version('tasks') - if api_version == '2018-09-01': - from ..v2018_09_01.aio.operations import TasksOperations as OperationClass - elif api_version == '2019-04-01': - from ..v2019_04_01.aio.operations import TasksOperations as OperationClass - elif api_version == '2019-06-01-preview': + if api_version == '2019-06-01-preview': 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)) @@ -849,15 +563,9 @@ def tokens(self): * 2019-05-01-preview: :class:`TokensOperations` * 2020-11-01-preview: :class:`TokensOperations` - * 2021-06-01-preview: :class:`TokensOperations` * 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` - * 2023-06-01-preview: :class:`TokensOperations` - * 2023-07-01: :class:`TokensOperations` - * 2023-08-01-preview: :class:`TokensOperations` * 2023-11-01-preview: :class:`TokensOperations` * 2024-11-01-preview: :class:`TokensOperations` """ @@ -866,24 +574,12 @@ def tokens(self): from ..v2019_05_01_preview.aio.operations import TokensOperations as OperationClass elif api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import TokensOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import TokensOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import TokensOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import TokensOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import TokensOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import TokensOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import TokensOperations as OperationClass elif api_version == '2024-11-01-preview': @@ -897,52 +593,25 @@ def tokens(self): def webhooks(self): """Instance depends on the API version: - * 2017-10-01: :class:`WebhooksOperations` * 2019-05-01: :class:`WebhooksOperations` - * 2019-12-01-preview: :class:`WebhooksOperations` * 2020-11-01-preview: :class:`WebhooksOperations` - * 2021-06-01-preview: :class:`WebhooksOperations` * 2021-08-01-preview: :class:`WebhooksOperations` - * 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` - * 2023-06-01-preview: :class:`WebhooksOperations` - * 2023-07-01: :class:`WebhooksOperations` - * 2023-08-01-preview: :class:`WebhooksOperations` * 2023-11-01-preview: :class:`WebhooksOperations` * 2024-11-01-preview: :class:`WebhooksOperations` """ api_version = self._get_api_version('webhooks') - if api_version == '2017-10-01': - from ..v2017_10_01.aio.operations import WebhooksOperations as OperationClass - elif api_version == '2019-05-01': + if api_version == '2019-05-01': from ..v2019_05_01.aio.operations import WebhooksOperations as OperationClass - elif api_version == '2019-12-01-preview': - from ..v2019_12_01_preview.aio.operations import WebhooksOperations as OperationClass elif api_version == '2020-11-01-preview': from ..v2020_11_01_preview.aio.operations import WebhooksOperations as OperationClass - elif api_version == '2021-06-01-preview': - from ..v2021_06_01_preview.aio.operations import WebhooksOperations as OperationClass elif api_version == '2021-08-01-preview': from ..v2021_08_01_preview.aio.operations import WebhooksOperations as OperationClass - elif api_version == '2021-09-01': - from ..v2021_09_01.aio.operations import WebhooksOperations as OperationClass - elif api_version == '2021-12-01-preview': - 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 - elif api_version == '2023-06-01-preview': - from ..v2023_06_01_preview.aio.operations import WebhooksOperations as OperationClass - elif api_version == '2023-07-01': - from ..v2023_07_01.aio.operations import WebhooksOperations as OperationClass - elif api_version == '2023-08-01-preview': - from ..v2023_08_01_preview.aio.operations import WebhooksOperations as OperationClass elif api_version == '2023-11-01-preview': from ..v2023_11_01_preview.aio.operations import WebhooksOperations as OperationClass elif api_version == '2024-11-01-preview': 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 7add64c1ca62..de53896b403e 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/models.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/models.py @@ -4,6 +4,4 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from .v2019_04_01.models import * -from .v2019_06_01_preview.models import * -from .v2023_07_01.models import * +from .v2019_05_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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 3214131de6e8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2017-03-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index 0c8bd93bdd35..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_container_registry_management_client.py +++ /dev/null @@ -1,116 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import Operations, RegistriesOperations - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: - """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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "2017-03-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-03-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index 1e42d3e14094..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2017-03-01", - "total_api_version_list": ["2017-03-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "registries": "RegistriesOperations", - "operations": "Operations" - } -} 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index cf95f28dbeda..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2017-03-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index 674211c67e34..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_container_registry_management_client.py +++ /dev/null @@ -1,119 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import Operations, RegistriesOperations - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "2017-03-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-03-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index a3043bb48959..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index e14e55af00bc..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2017_03_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 041a702bbf6f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/aio/operations/_registries_operations.py +++ /dev/null @@ -1,961 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2017_03_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry_create_parameters: Union[_models.RegistryCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_create_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryCreateParameters, IO[bytes]], - **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. Is either - a RegistryCreateParameters type or a IO[bytes] type. Required. - :type registry_create_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - registry_create_parameters=registry_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def delete(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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters or IO[bytes] - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index fcad468e2bf7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/__init__.py +++ /dev/null @@ -1,66 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - OperationDefinition, - OperationDisplayDefinition, - OperationListResult, - RegenerateCredentialParameters, - Registry, - RegistryCreateParameters, - RegistryListCredentialsResult, - RegistryListResult, - RegistryNameCheckRequest, - RegistryNameStatus, - RegistryPassword, - RegistryUpdateParameters, - Resource, - Sku, - StorageAccountParameters, - StorageAccountProperties, -) - -from ._container_registry_management_client_enums import ( # type: ignore - PasswordName, - ProvisioningState, - SkuTier, -) -from ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 2a227af999ea..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,30 +0,0 @@ -# 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 PasswordName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The password name.""" - - PASSWORD = "password" - PASSWORD2 = "password2" - - -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(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 deleted file mode 100644 index b313a5025c77..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_models_py3.py +++ /dev/null @@ -1,664 +0,0 @@ -# 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 typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -class OperationDefinition(_serialization.Model): - """The definition of a container registry operation. - - :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.v2017_03_01.models.OperationDisplayDefinition - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplayDefinition"}, - } - - def __init__( - self, - *, - name: Optional[str] = None, - display: Optional["_models.OperationDisplayDefinition"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2017_03_01.models.OperationDisplayDefinition - """ - super().__init__(**kwargs) - self.name = name - self.display = display - - -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: Any - ) -> None: - """ - :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.v2017_03_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: Any - ) -> None: - """ - :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.v2017_03_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 RegenerateCredentialParameters(_serialization.Model): - """The parameters used to regenerate the login credential. - - All required parameters must be populated in order to send to server. - - :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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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().__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 server. - - :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] - """ - - _validation = { - "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}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :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 - - -class Registry(Resource): - """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 server. - - :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 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. 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. - :vartype admin_user_enabled: bool - :ivar storage_account: The properties of the storage account for the container registry. - :vartype storage_account: - ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountProperties - """ - - _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}, - } - - _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"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - admin_user_enabled: bool = False, - storage_account: Optional["_models.StorageAccountProperties"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2017_03_01.models.Sku - :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. - :paramtype admin_user_enabled: bool - :keyword storage_account: The properties of the storage account for the container registry. - :paramtype storage_account: - ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountProperties - """ - super().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.login_server = None - self.creation_date = None - self.provisioning_state = None - self.admin_user_enabled = admin_user_enabled - self.storage_account = storage_account - - -class RegistryCreateParameters(_serialization.Model): - """The parameters for creating a container registry. - - All required parameters must be populated in order to send to server. - - :ivar tags: The tags for the container registry. - :vartype tags: dict[str, str] - :ivar location: The location of the container registry. This cannot be changed after the - resource is created. Required. - :vartype location: str - :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 - :ivar storage_account: The parameters of a storage account for the container registry. If - specified, the storage account must be in the same physical location as the container registry. - :vartype storage_account: - ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountParameters - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - admin_user_enabled: bool = False, - storage_account: Optional["_models.StorageAccountParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: The tags for the container registry. - :paramtype tags: dict[str, str] - :keyword location: The location of the container registry. This cannot be changed after the - resource is created. Required. - :paramtype location: str - :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 - :keyword storage_account: The parameters of a storage account for the container registry. If - specified, the storage account must be in the same physical location as the container registry. - :paramtype storage_account: - ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountParameters - """ - super().__init__(**kwargs) - self.tags = tags - self.location = location - self.sku = sku - self.admin_user_enabled = admin_user_enabled - self.storage_account = storage_account - - -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.v2017_03_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: Any - ) -> None: - """ - :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.v2017_03_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.v2017_03_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: Any - ) -> None: - """ - :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.v2017_03_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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.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"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__init__(**kwargs) - self.name = name - self.value = value - - -class RegistryUpdateParameters(_serialization.Model): - """The parameters for updating a 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 - :ivar storage_account: The parameters of a storage account for the container registry. If - specified, the storage account must be in the same physical location as the container registry. - :vartype storage_account: - ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountParameters - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "admin_user_enabled": {"key": "properties.adminUserEnabled", "type": "bool"}, - "storage_account": {"key": "properties.storageAccount", "type": "StorageAccountParameters"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - admin_user_enabled: Optional[bool] = None, - storage_account: Optional["_models.StorageAccountParameters"] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword storage_account: The parameters of a storage account for the container registry. If - specified, the storage account must be in the same physical location as the container registry. - :paramtype storage_account: - ~azure.mgmt.containerregistry.v2017_03_01.models.StorageAccountParameters - """ - super().__init__(**kwargs) - self.tags = tags - self.admin_user_enabled = admin_user_enabled - self.storage_account = storage_account - - -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 server. - - :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. "Basic" - :vartype tier: str or ~azure.mgmt.containerregistry.v2017_03_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: str, **kwargs: Any) -> None: - """ - :keyword name: The SKU name of the container registry. Required for registry creation. Allowed - value: Basic. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.name = name - self.tier = None - - -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 server. - - :ivar name: The name of the storage account. Required. - :vartype name: str - :ivar access_key: The access key to the storage account. Required. - :vartype access_key: str - """ - - _validation = { - "name": {"required": True}, - "access_key": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "access_key": {"key": "accessKey", "type": "str"}, - } - - def __init__(self, *, name: str, access_key: str, **kwargs: Any) -> None: - """ - :keyword name: The name of the storage account. Required. - :paramtype name: str - :keyword access_key: The access key to the storage account. Required. - :paramtype access_key: str - """ - super().__init__(**kwargs) - self.name = name - self.access_key = access_key - - -class StorageAccountProperties(_serialization.Model): - """The properties of a storage account for a container registry. - - :ivar name: The name of the storage account. - :vartype name: str - """ - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword name: The name of the storage account. - :paramtype name: str - """ - 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index a3043bb48959..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "Operations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 357350ab70e7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_operations.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - _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.v2017_03_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 0c9b885435f5..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/operations/_registries_operations.py +++ /dev/null @@ -1,1233 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), - } - - _url: str = _url.format(**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_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: str = 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" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2017_03_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - registry_create_parameters: Union[_models.RegistryCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_create_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryCreateParameters, IO[bytes]], - **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. Is either - a RegistryCreateParameters type or a IO[bytes] type. Required. - :type registry_create_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - registry_create_parameters=registry_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: None or the result of cls(response) - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryUpdateParameters or IO[bytes] - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_03_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_03_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-03-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_03_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 43281338ce1a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2017-10-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index 11feaa870299..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_container_registry_management_client.py +++ /dev/null @@ -1,125 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import Operations, RegistriesOperations, ReplicationsOperations, WebhooksOperations - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: azure.mgmt.containerregistry.v2017_10_01.operations.RegistriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2017_10_01.operations.Operations - :ivar replications: ReplicationsOperations operations - :vartype replications: - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "2017-10-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-10-01") - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-10-01" - ) - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2017-10-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index a840faf39d74..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_metadata.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "chosen_version": "2017-10-01", - "total_api_version_list": ["2017-10-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "registries": "RegistriesOperations", - "operations": "Operations", - "replications": "ReplicationsOperations", - "webhooks": "WebhooksOperations" - } -} 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 0693d2db6671..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2017-10-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index dc2adda9c079..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_container_registry_management_client.py +++ /dev/null @@ -1,128 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import Operations, RegistriesOperations, ReplicationsOperations, WebhooksOperations - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2017_10_01.aio.operations.RegistriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2017_10_01.aio.operations.Operations - :ivar replications: ReplicationsOperations operations - :vartype replications: - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "2017-10-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2017-10-01") - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2017-10-01" - ) - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2017-10-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index 8ac7d18af686..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "Operations", - "ReplicationsOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 29f498520593..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2017_10_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 70cd757ae7ee..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1574 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2017_10_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - async def begin_update( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryPolicies or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.RegistryPolicies] = kwargs.pop("cls", None) - - _request = build_list_policies_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_policies_initial( - self, - resource_group_name: str, - registry_name: str, - registry_policies_update_parameters: Union[_models.RegistryPolicies, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_policies_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryPolicies, IO[bytes]], - **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. Is either a RegistryPolicies type or a IO[bytes] type. Required. - :type registry_policies_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - registry_policies_update_parameters=registry_policies_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RegistryPolicies", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.RegistryPolicies].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.RegistryPolicies]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 6502c1b6701b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_replications_operations.py +++ /dev/null @@ -1,735 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2017_10_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index ea37bcf3f5c8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,947 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2017_10_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 4614c4a9e975..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/__init__.py +++ /dev/null @@ -1,144 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - Action, - DefaultAction, - ImportMode, - PasswordName, - PolicyStatus, - ProvisioningState, - RegistryUsageUnit, - SkuName, - SkuTier, - TrustPolicyType, - WebhookAction, - WebhookStatus, -) -from ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index f795ea138eb9..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,105 +0,0 @@ -# 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 virtual network rule.""" - - ALLOW = "Allow" - - -class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The default action of allow or deny when no other rules match.""" - - ALLOW = "Allow" - DENY = "Deny" - - -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 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 the container registry at the time the operation was called.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - - -class RegistryUsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of measurement.""" - - COUNT = "Count" - BYTES = "Bytes" - - -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 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" 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 deleted file mode 100644 index 5396165a0050..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_models_py3.py +++ /dev/null @@ -1,2039 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 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: Any) -> None: # 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.v2017_10_01.models.EventRequestMessage - :ivar event_response_message: The event response message received from the service URI. - :vartype event_response_message: - ~azure.mgmt.containerregistry.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_01.models.EventRequestMessage - :keyword event_response_message: The event response message received from the service URI. - :paramtype event_response_message: - ~azure.mgmt.containerregistry.v2017_10_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.v2017_10_01.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2017_10_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.v2017_10_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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_01.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2017_10_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.v2017_10_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.v2017_10_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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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.v2017_10_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2017_10_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: Any - ) -> None: - """ - :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 ImportImageParameters(_serialization.Model): - """ImportImageParameters. - - All required parameters must be populated in order to send to server. - - :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). - :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.v2017_10_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: Any - ) -> None: - """ - :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). - :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.v2017_10_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 server. - - :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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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 server. - - :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: Any) -> None: - """ - :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 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 server. - - :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: 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: Optional[Union[str, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: 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 NetworkRuleSet(_serialization.Model): - """The network rule set for a container registry. - - All required parameters must be populated in order to send to server. - - :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: - list[~azure.mgmt.containerregistry.v2017_10_01.models.VirtualNetworkRule] - :ivar ip_rules: The IP ACL rules. - :vartype ip_rules: list[~azure.mgmt.containerregistry.v2017_10_01.models.IPRule] - """ - - _validation = { - "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]"}, - } - - def __init__( - self, - *, - default_action: Union[str, "_models.DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, - ip_rules: Optional[List["_models.IPRule"]] = None, - **kwargs: Any - ) -> None: - """ - :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. - :paramtype virtual_network_rules: - list[~azure.mgmt.containerregistry.v2017_10_01.models.VirtualNetworkRule] - :keyword ip_rules: The IP ACL rules. - :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2017_10_01.models.IPRule] - """ - super().__init__(**kwargs) - self.default_action = default_action - self.virtual_network_rules = virtual_network_rules - 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.v2017_10_01.models.OperationDisplayDefinition - :ivar service_specification: The definition of Azure Monitoring service. - :vartype service_specification: - ~azure.mgmt.containerregistry.v2017_10_01.models.OperationServiceSpecificationDefinition - """ - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplayDefinition"}, - "service_specification": { - "key": "properties.serviceSpecification", - "type": "OperationServiceSpecificationDefinition", - }, - } - - def __init__( - self, - *, - origin: Optional[str] = None, - name: Optional[str] = None, - display: Optional["_models.OperationDisplayDefinition"] = None, - service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2017_10_01.models.OperationDisplayDefinition - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2017_10_01.models.OperationServiceSpecificationDefinition - """ - super().__init__(**kwargs) - self.origin = origin - self.name = name - self.display = display - 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: Any - ) -> None: - """ - :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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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 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: Any - ) -> None: - """ - :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 metrics list. - - :ivar metric_specifications: A list of Azure Monitoring metrics definition. - :vartype metric_specifications: - list[~azure.mgmt.containerregistry.v2017_10_01.models.OperationMetricSpecificationDefinition] - """ - - _attribute_map = { - "metric_specifications": {"key": "metricSpecifications", "type": "[OperationMetricSpecificationDefinition]"}, - } - - def __init__( - self, - *, - metric_specifications: Optional[List["_models.OperationMetricSpecificationDefinition"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2017_10_01.models.OperationMetricSpecificationDefinition] - """ - super().__init__(**kwargs) - self.metric_specifications = metric_specifications - - -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. 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"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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().__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 server. - - :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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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().__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 server. - - :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] - """ - - _validation = { - "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}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :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 - - -class Registry(Resource): - """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 server. - - :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 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. 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. - :vartype status: ~azure.mgmt.containerregistry.v2017_10_01.models.Status - :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. - :vartype admin_user_enabled: bool - :ivar storage_account: The properties of the storage account for the container registry. Only - applicable to Classic SKU. - :vartype storage_account: - ~azure.mgmt.containerregistry.v2017_10_01.models.StorageAccountProperties - :ivar network_rule_set: The network rule set for a container registry. - :vartype network_rule_set: ~azure.mgmt.containerregistry.v2017_10_01.models.NetworkRuleSet - """ - - _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}, - } - - _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"}, - } - - def __init__( - self, - *, - location: str, - sku: "_models.Sku", - tags: Optional[Dict[str, str]] = None, - admin_user_enabled: bool = False, - storage_account: Optional["_models.StorageAccountProperties"] = None, - network_rule_set: Optional["_models.NetworkRuleSet"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2017_10_01.models.Sku - :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. - :paramtype admin_user_enabled: bool - :keyword storage_account: The properties of the storage account for the container registry. - Only applicable to Classic SKU. - :paramtype storage_account: - ~azure.mgmt.containerregistry.v2017_10_01.models.StorageAccountProperties - :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().__init__(location=location, tags=tags, **kwargs) - self.sku = sku - self.login_server = None - self.creation_date = None - self.provisioning_state = None - self.status = None - self.admin_user_enabled = admin_user_enabled - self.storage_account = storage_account - self.network_rule_set = network_rule_set - - -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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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.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"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__init__(**kwargs) - self.name = name - self.value = value - - -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. - :vartype quarantine_policy: ~azure.mgmt.containerregistry.v2017_10_01.models.QuarantinePolicy - :ivar trust_policy: An object that represents content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2017_10_01.models.TrustPolicy - """ - - _attribute_map = { - "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, - "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, - } - - def __init__( - self, - *, - quarantine_policy: Optional["_models.QuarantinePolicy"] = None, - trust_policy: Optional["_models.TrustPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword quarantine_policy: An object that represents quarantine policy for a container - registry. - :paramtype quarantine_policy: ~azure.mgmt.containerregistry.v2017_10_01.models.QuarantinePolicy - :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().__init__(**kwargs) - self.quarantine_policy = quarantine_policy - self.trust_policy = trust_policy - - -class RegistryUpdateParameters(_serialization.Model): - """The parameters for updating a 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 - :ivar admin_user_enabled: The value that indicates whether the admin user is enabled. - :vartype admin_user_enabled: bool - :ivar storage_account: The parameters of a storage account for the container registry. Only - applicable to Classic SKU. If specified, the storage account must be in the same physical - location as the container registry. - :vartype storage_account: - ~azure.mgmt.containerregistry.v2017_10_01.models.StorageAccountProperties - :ivar network_rule_set: The network rule set for a container registry. - :vartype network_rule_set: ~azure.mgmt.containerregistry.v2017_10_01.models.NetworkRuleSet - """ - - _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"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - admin_user_enabled: Optional[bool] = None, - storage_account: Optional["_models.StorageAccountProperties"] = None, - network_rule_set: Optional["_models.NetworkRuleSet"] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword admin_user_enabled: The value that indicates whether the admin user is enabled. - :paramtype admin_user_enabled: bool - :keyword storage_account: The parameters of a storage account for the container registry. Only - applicable to Classic SKU. If specified, the storage account must be in the same physical - location as the container registry. - :paramtype storage_account: - ~azure.mgmt.containerregistry.v2017_10_01.models.StorageAccountProperties - :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().__init__(**kwargs) - self.tags = tags - self.sku = sku - self.admin_user_enabled = admin_user_enabled - self.storage_account = storage_account - self.network_rule_set = network_rule_set - - -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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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.v2017_10_01.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2017_10_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 server. - - :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 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.v2017_10_01.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2017_10_01.models.Status - """ - - _validation = { - "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"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :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__(location=location, tags=tags, **kwargs) - self.provisioning_state = None - self.status = None - - -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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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] - """ - - _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - } - - def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :keyword tags: The tags for the replication. - :paramtype tags: dict[str, str] - """ - super().__init__(**kwargs) - self.tags = tags - - -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: Any - ) -> None: - """ - :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 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 server. - - :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. 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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: - """ - :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().__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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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 server. - - :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: Any) -> None: # pylint: disable=redefined-builtin - """ - :keyword id: The resource ID of the storage account. Required. - :paramtype id: str - """ - super().__init__(**kwargs) - self.id = id - - -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: Any - ) -> None: - """ - :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 TrustPolicy(_serialization.Model): - """An object that represents content trust policy for a container registry. - - :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. 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"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.TrustPolicyType"]] = None, - status: Optional[Union[str, "_models.PolicyStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :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. Known values - are: "enabled" and "disabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2017_10_01.models.PolicyStatus - """ - super().__init__(**kwargs) - self.type = type - self.status = status - - -class VirtualNetworkRule(_serialization.Model): - """Virtual network rule. - - All required parameters must be populated in order to send to server. - - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :vartype virtual_network_resource_id: str - """ - - _validation = { - "virtual_network_resource_id": {"required": True}, - } - - _attribute_map = { - "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, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :paramtype virtual_network_resource_id: str - """ - super().__init__(**kwargs) - self.action = action - self.virtual_network_resource_id = virtual_network_resource_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 server. - - :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 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. - '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.v2017_10_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.v2017_10_01.models.ProvisioningState - """ - - _validation = { - "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"}, - } - - 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: Any - ) -> None: - """ - :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.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' - 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.v2017_10_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 server. - - :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.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. - '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.v2017_10_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: Any - ) -> None: - """ - :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.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' - 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.v2017_10_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.v2017_10_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: Any - ) -> None: - """ - :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.v2017_10_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.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. - '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.v2017_10_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: Any - ) -> None: - """ - :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.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' - 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.v2017_10_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/v2017_10_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 8ac7d18af686..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/__init__.py +++ /dev/null @@ -1,31 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "Operations", - "ReplicationsOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 2843184f2c71..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_operations.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - _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.v2017_10_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index ed2ecb5acf87..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_registries_operations.py +++ /dev/null @@ -1,1967 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), - } - - _url: str = _url.format(**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_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: str = 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" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_policies_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_update_policies_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2017_10_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2017_10_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2017_10_01.models.Registry or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryPolicies or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.RegistryPolicies] = kwargs.pop("cls", None) - - _request = build_list_policies_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_policies_initial( - self, - resource_group_name: str, - registry_name: str, - registry_policies_update_parameters: Union[_models.RegistryPolicies, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_policies_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryPolicies, IO[bytes]], - **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. Is either a RegistryPolicies type or a IO[bytes] type. Required. - :type registry_policies_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.RegistryPolicies or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - registry_policies_update_parameters=registry_policies_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("RegistryPolicies", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.RegistryPolicies].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.RegistryPolicies]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 6962cb936528..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_replications_operations.py +++ /dev/null @@ -1,908 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2017_10_01.models.Replication or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.ReplicationUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 4298adc5d32d..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/operations/_webhooks_operations.py +++ /dev/null @@ -1,1208 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2017_10_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2017_10_01.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2017_10_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2017-10-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2017_10_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 98f6942f0be6..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2018-09-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index 3f327f876822..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_container_registry_management_client.py +++ /dev/null @@ -1,119 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import RegistriesOperations, RunsOperations, TasksOperations - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: azure.mgmt.containerregistry.v2018_09_01.operations.RegistriesOperations - :ivar runs: RunsOperations operations - :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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "2018-09-01" - ) - self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-09-01") - self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize, "2018-09-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index bd33460e99c5..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2018-09-01", - "total_api_version_list": ["2018-09-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "registries": "RegistriesOperations", - "runs": "RunsOperations", - "tasks": "TasksOperations" - } -} 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index f3aa6c30c002..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2018-09-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index e34949d70974..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_container_registry_management_client.py +++ /dev/null @@ -1,122 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import RegistriesOperations, RunsOperations, TasksOperations - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2018_09_01.aio.operations.RegistriesOperations - :ivar runs: RunsOperations operations - :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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "2018-09-01" - ) - self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize, "2018-09-01") - self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize, "2018-09-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index d57838606437..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._runs_operations import RunsOperations # type: ignore -from ._tasks_operations import TasksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "RunsOperations", - "TasksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 6b1d400c03e9..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_registries_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2018_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: Union[_models.RunRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_request, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: _models.RunRequest, - *, - 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: ~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 - :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_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RunRequest - type or a IO[bytes] type. Required. - :type run_request: ~azure.mgmt.containerregistry.v2018_09_01.models.RunRequest or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_request=run_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Run]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_build_source_upload_url( - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: SourceUploadDefinition or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.SourceUploadDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - - _request = build_get_build_source_upload_url_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index cd703f4e38cd..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_runs_operations.py +++ /dev/null @@ -1,599 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RunsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> 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. Required. - :type resource_group_name: str - :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', - 'Has', 'All' are allowed. Default value is None. - :type filter: str - :param top: $top is supported for get list of runs, which limits the maximum number of runs to - return. Default value is None. - :type top: int - :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.Run] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace_async - 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. 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 - :return: Run or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Run - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.Run] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **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. Is either a RunUpdateParameters type - or a IO[bytes] type. Required. - :type run_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_id=run_id, - run_update_parameters=run_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Run]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_log_sas_url( - 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. 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 - :return: RunGetLogResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.RunGetLogResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - - _request = build_get_log_sas_url_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _cancel_initial( - self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - run_id=run_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 5a5cc8dcbdd4..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/aio/operations/_tasks_operations.py +++ /dev/null @@ -1,789 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TasksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Task] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace_async - 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_create_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **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. Is either a Task type or a - IO[bytes] type. Required. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_create_parameters=task_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - task_name=task_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **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. Is either a - TaskUpdateParameters type or a IO[bytes] type. Required. - :type task_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_update_parameters=task_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_details_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 972132b4342e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/__init__.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - Architecture, - BaseImageDependencyType, - BaseImageTriggerType, - OS, - ProvisioningState, - RunStatus, - RunType, - SecretObjectType, - SourceControlType, - SourceRegistryLoginMode, - SourceTriggerEvent, - StepType, - TaskStatus, - TokenType, - TriggerStatus, - Variant, -) -from ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 9eb4698b6f62..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,142 +0,0 @@ -# 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 Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS architecture.""" - - AMD64 = "amd64" - X86 = "x86" - ARM = "arm" - - -class BaseImageDependencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the base image dependency.""" - - BUILD_TIME = "BuildTime" - RUN_TIME = "RunTime" - - -class BaseImageTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the auto trigger for base image dependency updates.""" - - ALL = "All" - RUNTIME = "Runtime" - - -class OS(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system type required for the run.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state of a run.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - - -class RunStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current status of the run.""" - - QUEUED = "Queued" - STARTED = "Started" - RUNNING = "Running" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - ERROR = "Error" - TIMEOUT = "Timeout" - - -class RunType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of run.""" - - QUICK_BUILD = "QuickBuild" - QUICK_RUN = "QuickRun" - AUTO_BUILD = "AutoBuild" - AUTO_RUN = "AutoRun" - - -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(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of source control service.""" - - GITHUB = "Github" - VISUAL_STUDIO_TEAM_SERVICE = "VisualStudioTeamService" - - -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 - the source registry during the run. - """ - - NONE = "None" - DEFAULT = "Default" - - -class SourceTriggerEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SourceTriggerEvent.""" - - COMMIT = "commit" - PULLREQUEST = "pullrequest" - - -class StepType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the step.""" - - DOCKER = "Docker" - FILE_TASK = "FileTask" - ENCODED_TASK = "EncodedTask" - - -class TaskStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current status of task.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class TokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Auth token.""" - - PAT = "PAT" - O_AUTH = "OAuth" - - -class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current status of trigger.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class Variant(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Variant of the CPU.""" - - V6 = "v6" - V7 = "v7" - V8 = "v8" 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 deleted file mode 100644 index 14496c176d25..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_models_py3.py +++ /dev/null @@ -1,2759 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -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. - :vartype cpu: int - """ - - _attribute_map = { - "cpu": {"key": "cpu", "type": "int"}, - } - - def __init__(self, *, cpu: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword cpu: The CPU configuration in terms of number of cores required for the run. - :paramtype cpu: int - """ - super().__init__(**kwargs) - self.cpu = cpu - - -class Argument(_serialization.Model): - """The properties of a run argument. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the argument. Required. - :vartype name: str - :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. - :vartype is_secret: bool - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "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: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the argument. Required. - :paramtype name: str - :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().__init__(**kwargs) - self.name = name - self.value = value - self.is_secret = is_secret - - -class AuthInfo(_serialization.Model): - """The authorization properties for accessing the source code repository. - - All required parameters must be populated in order to send to server. - - :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: 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 - :ivar scope: The scope of the access token. - :vartype scope: str - :ivar expires_in: Time in seconds that the token remains valid. - :vartype expires_in: int - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - token_type: Union[str, "_models.TokenType"], - token: str, - refresh_token: Optional[str] = None, - scope: Optional[str] = None, - expires_in: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :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: 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 - :keyword scope: The scope of the access token. - :paramtype scope: str - :keyword expires_in: Time in seconds that the token remains valid. - :paramtype expires_in: int - """ - super().__init__(**kwargs) - self.token_type = token_type - self.token = token - self.refresh_token = refresh_token - self.scope = scope - self.expires_in = expires_in - - -class AuthInfoUpdateParameters(_serialization.Model): - """The authorization properties for accessing the source code repository. - - :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 - :ivar refresh_token: The refresh token used to refresh the access token. - :vartype refresh_token: str - :ivar scope: The scope of the access token. - :vartype scope: str - :ivar expires_in: Time in seconds that the token remains valid. - :vartype expires_in: int - """ - - _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"}, - } - - def __init__( - self, - *, - token_type: Optional[Union[str, "_models.TokenType"]] = None, - token: Optional[str] = None, - refresh_token: Optional[str] = None, - scope: Optional[str] = None, - expires_in: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword refresh_token: The refresh token used to refresh the access token. - :paramtype refresh_token: str - :keyword scope: The scope of the access token. - :paramtype scope: str - :keyword expires_in: Time in seconds that the token remains valid. - :paramtype expires_in: int - """ - super().__init__(**kwargs) - self.token_type = token_type - self.token = token - self.refresh_token = refresh_token - self.scope = scope - self.expires_in = expires_in - - -class BaseImageDependency(_serialization.Model): - """Properties that describe a base image dependency. - - :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 - :ivar repository: The repository name. - :vartype repository: str - :ivar tag: The tag name. - :vartype tag: str - :ivar digest: The sha256-based digest of the image manifest. - :vartype digest: str - """ - - _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"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.BaseImageDependencyType"]] = None, - registry: Optional[str] = None, - repository: Optional[str] = None, - tag: Optional[str] = None, - digest: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword registry: The registry login server. - :paramtype registry: str - :keyword repository: The repository name. - :paramtype repository: str - :keyword tag: The tag name. - :paramtype tag: str - :keyword digest: The sha256-based digest of the image manifest. - :paramtype digest: str - """ - super().__init__(**kwargs) - self.type = type - self.registry = registry - self.repository = repository - self.tag = tag - self.digest = digest - - -class BaseImageTrigger(_serialization.Model): - """The trigger based on base image dependency. - - All required parameters must be populated in order to send to server. - - :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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - base_image_trigger_type: Union[str, "_models.BaseImageTriggerType"], - name: str, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.base_image_trigger_type = base_image_trigger_type - self.status = status - self.name = name - - -class BaseImageTriggerUpdateParameters(_serialization.Model): - """The properties for updating base image dependency trigger. - - All required parameters must be populated in order to send to server. - - :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. - 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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "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, "_models.BaseImageTriggerType"]] = None, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword base_image_trigger_type: The type of the auto trigger for base image dependency - 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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.base_image_trigger_type = base_image_trigger_type - self.status = status - self.name = name - - -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. - :vartype source_registry: - ~azure.mgmt.containerregistry.v2018_09_01.models.SourceRegistryCredentials - :ivar custom_registries: Describes the credential parameters for accessing other custom - registries. The key - for the dictionary item will be the registry login server (myregistry.azurecr.io) and - the value of the item will be the registry credentials for accessing the registry. - :vartype custom_registries: dict[str, - ~azure.mgmt.containerregistry.v2018_09_01.models.CustomRegistryCredentials] - """ - - _attribute_map = { - "source_registry": {"key": "sourceRegistry", "type": "SourceRegistryCredentials"}, - "custom_registries": {"key": "customRegistries", "type": "{CustomRegistryCredentials}"}, - } - - def __init__( - self, - *, - source_registry: Optional["_models.SourceRegistryCredentials"] = None, - custom_registries: Optional[Dict[str, "_models.CustomRegistryCredentials"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_registry: Describes the credential parameters for accessing the source - registry. - :paramtype source_registry: - ~azure.mgmt.containerregistry.v2018_09_01.models.SourceRegistryCredentials - :keyword custom_registries: Describes the credential parameters for accessing other custom - registries. The key - for the dictionary item will be the registry login server (myregistry.azurecr.io) and - the value of the item will be the registry credentials for accessing the registry. - :paramtype custom_registries: dict[str, - ~azure.mgmt.containerregistry.v2018_09_01.models.CustomRegistryCredentials] - """ - super().__init__(**kwargs) - self.source_registry = source_registry - self.custom_registries = custom_registries - - -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. - :vartype user_name: ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObject - :ivar password: The password for logging into the custom registry. The password is a secret - object that allows multiple ways of providing the value for it. - :vartype password: ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObject - """ - - _attribute_map = { - "user_name": {"key": "userName", "type": "SecretObject"}, - "password": {"key": "password", "type": "SecretObject"}, - } - - def __init__( - self, - *, - user_name: Optional["_models.SecretObject"] = None, - password: Optional["_models.SecretObject"] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_name: The username for logging into the custom registry. - :paramtype user_name: ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObject - :keyword password: The password for logging into the custom registry. The password is a secret - object that allows multiple ways of providing the value for it. - :paramtype password: ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObject - """ - super().__init__(**kwargs) - self.user_name = user_name - self.password = password - - -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 - - 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 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 - """ - - _validation = { - "type": {"required": True, "readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, - } - - _subtype_map = { - "type": { - "DockerBuildRequest": "DockerBuildRequest", - "EncodedTaskRunRequest": "EncodedTaskRunRequest", - "FileTaskRunRequest": "FileTaskRunRequest", - "TaskRunRequest": "TaskRunRequest", - } - } - - def __init__(self, *, is_archive_enabled: bool = False, **kwargs: Any) -> None: - """ - :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run - or not. - :paramtype is_archive_enabled: bool - """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.is_archive_enabled = is_archive_enabled - - -class DockerBuildRequest(RunRequest): - """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 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 image_names: The fully qualified image names including the repository and tag. - :vartype image_names: list[str] - :ivar is_push_enabled: The value of this property indicates whether the image built should be - pushed to the registry or not. - :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: 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 - :ivar arguments: The collection of override arguments to be used when executing the run. - :vartype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :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 - :ivar source_location: The URL(absolute or relative) of the source context. It can be an URL to - a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :vartype source_location: str - :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 = { - "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"}, - } - - def __init__( - self, - *, - docker_file_path: str, - platform: "_models.PlatformProperties", - is_archive_enabled: bool = False, - image_names: Optional[List[str]] = None, - is_push_enabled: bool = True, - no_cache: bool = False, - target: Optional[str] = None, - arguments: Optional[List["_models.Argument"]] = None, - timeout: int = 3600, - agent_configuration: Optional["_models.AgentProperties"] = None, - source_location: Optional[str] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run - or not. - :paramtype is_archive_enabled: bool - :keyword image_names: The fully qualified image names including the repository and tag. - :paramtype image_names: list[str] - :keyword is_push_enabled: The value of this property indicates whether the image built should - be pushed to the registry or not. - :paramtype is_push_enabled: bool - :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: 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 - :keyword arguments: The collection of override arguments to be used when executing the run. - :paramtype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :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: - ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties - :keyword source_location: The URL(absolute or relative) of the source context. It can be an URL - to a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :paramtype source_location: str - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials - """ - 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 - self.docker_file_path = docker_file_path - self.target = target - self.arguments = arguments - self.timeout = timeout - self.platform = platform - self.agent_configuration = agent_configuration - self.source_location = source_location - self.credentials = credentials - - -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 - - 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 server. - - :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: - list[~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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 - """ - - _validation = { - "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"}, - } - - _subtype_map = {"type": {"Docker": "DockerBuildStep", "EncodedTask": "EncodedTaskStep", "FileTask": "FileTaskStep"}} - - def __init__( - self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 - """ - 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 - - -class DockerBuildStep(TaskStepProperties): - """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 server. - - :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: - list[~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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 image_names: The fully qualified image names including the repository and tag. - :vartype image_names: list[str] - :ivar is_push_enabled: The value of this property indicates whether the image built should be - pushed to the registry or not. - :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: 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 - :ivar arguments: The collection of override arguments to be used when executing this build - step. - :vartype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] - """ - - _validation = { - "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]"}, - } - - def __init__( - self, - *, - docker_file_path: str, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - image_names: Optional[List[str]] = None, - is_push_enabled: bool = True, - no_cache: bool = False, - target: Optional[str] = None, - arguments: Optional[List["_models.Argument"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 image_names: The fully qualified image names including the repository and tag. - :paramtype image_names: list[str] - :keyword is_push_enabled: The value of this property indicates whether the image built should - be pushed to the registry or not. - :paramtype is_push_enabled: bool - :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: 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 - :keyword arguments: The collection of override arguments to be used when executing this build - step. - :paramtype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] - """ - 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 - self.docker_file_path = docker_file_path - self.target = target - self.arguments = arguments - - -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 - - 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 server. - - :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 - :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 - """ - - _validation = { - "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"}, - } - - _subtype_map = { - "type": { - "Docker": "DockerBuildStepUpdateParameters", - "EncodedTask": "EncodedTaskStepUpdateParameters", - "FileTask": "FileTaskStepUpdateParameters", - } - } - - def __init__( - self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 - """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.context_path = context_path - self.context_access_token = context_access_token - - -class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): - """The properties for updating a 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 server. - - :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 - :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 image_names: The fully qualified image names including the repository and tag. - :vartype image_names: list[str] - :ivar is_push_enabled: The value of this property indicates whether the image built should be - pushed to the registry or not. - :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: The Docker file path relative to the source context. - :vartype docker_file_path: str - :ivar arguments: The collection of override arguments to be used when executing this build - step. - :vartype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] - :ivar target: The name of the target build stage for the docker build. - :vartype target: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = None, - no_cache: Optional[bool] = None, - docker_file_path: Optional[str] = None, - arguments: Optional[List["_models.Argument"]] = None, - target: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 image_names: The fully qualified image names including the repository and tag. - :paramtype image_names: list[str] - :keyword is_push_enabled: The value of this property indicates whether the image built should - be pushed to the registry or not. - :paramtype is_push_enabled: bool - :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: The Docker file path relative to the source context. - :paramtype docker_file_path: str - :keyword arguments: The collection of override arguments to be used when executing this build - step. - :paramtype arguments: list[~azure.mgmt.containerregistry.v2018_09_01.models.Argument] - :keyword target: The name of the target build stage for the docker build. - :paramtype target: 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 - self.docker_file_path = docker_file_path - self.arguments = arguments - self.target = target - - -class EncodedTaskRunRequest(RunRequest): - """The parameters for a quick task run request. - - 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 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: 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 - :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] - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :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 - :ivar source_location: The URL(absolute or relative) of the source context. It can be an URL to - a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :vartype source_location: str - :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 = { - "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"}, - } - - def __init__( - self, - *, - encoded_task_content: str, - platform: "_models.PlatformProperties", - is_archive_enabled: bool = False, - encoded_values_content: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - timeout: int = 3600, - agent_configuration: Optional["_models.AgentProperties"] = None, - source_location: Optional[str] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :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: 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] - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :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: - ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties - :keyword source_location: The URL(absolute or relative) of the source context. It can be an URL - to a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :paramtype source_location: str - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials - """ - 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 - self.timeout = timeout - self.platform = platform - self.agent_configuration = agent_configuration - self.source_location = source_location - self.credentials = credentials - - -class EncodedTaskStep(TaskStepProperties): - """The properties of a encoded task 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 server. - - :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: - list[~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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: 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 - :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}, - "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]"}, - } - - def __init__( - self, - *, - encoded_task_content: str, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - encoded_values_content: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: 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().__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 EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): - """The properties for updating encoded task 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 server. - - :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 - :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: Base64 encoded value of the template/definition file content. - :vartype encoded_task_content: str - :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. - :vartype encoded_values_content: 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}, - } - - _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]"}, - } - - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - encoded_task_content: Optional[str] = None, - encoded_values_content: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: Base64 encoded value of the template/definition file content. - :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().__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 FileTaskRunRequest(RunRequest): - """The request parameters for a scheduling run against a task file. - - 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 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: 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 - :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] - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :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 - :ivar source_location: The URL(absolute or relative) of the source context. It can be an URL to - a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :vartype source_location: str - :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 = { - "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"}, - } - - def __init__( - self, - *, - task_file_path: str, - platform: "_models.PlatformProperties", - is_archive_enabled: bool = False, - values_file_path: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - timeout: int = 3600, - agent_configuration: Optional["_models.AgentProperties"] = None, - source_location: Optional[str] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :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: 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 - :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] - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :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: - ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties - :keyword source_location: The URL(absolute or relative) of the source context. It can be an URL - to a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :paramtype source_location: str - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials - """ - 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 - self.timeout = timeout - self.platform = platform - self.agent_configuration = agent_configuration - self.source_location = source_location - self.credentials = credentials - - -class FileTaskStep(TaskStepProperties): - """The properties of a task 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 server. - - :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: - list[~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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: 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 - :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}, - "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]"}, - } - - def __init__( - self, - *, - task_file_path: str, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - values_file_path: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: 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().__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 FileTaskStepUpdateParameters(TaskStepUpdateParameters): - """The properties of updating a task 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 server. - - :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 - :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: The task template/definition file path relative to the source context. - :vartype task_file_path: str - :ivar values_file_path: The values/parameters file path relative to the source context. - :vartype values_file_path: 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}, - } - - _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]"}, - } - - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - task_file_path: Optional[str] = None, - values_file_path: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: The task template/definition file path relative to the source context. - :paramtype task_file_path: str - :keyword values_file_path: The 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().__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(_serialization.Model): - """Properties for a registry image. - - :ivar registry: The registry login server. - :vartype registry: str - :ivar repository: The repository name. - :vartype repository: str - :ivar tag: The tag name. - :vartype tag: str - :ivar digest: The sha256-based digest of the image manifest. - :vartype digest: str - """ - - _attribute_map = { - "registry": {"key": "registry", "type": "str"}, - "repository": {"key": "repository", "type": "str"}, - "tag": {"key": "tag", "type": "str"}, - "digest": {"key": "digest", "type": "str"}, - } - - def __init__( - self, - *, - registry: Optional[str] = None, - repository: Optional[str] = None, - tag: Optional[str] = None, - digest: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword registry: The registry login server. - :paramtype registry: str - :keyword repository: The repository name. - :paramtype repository: str - :keyword tag: The tag name. - :paramtype tag: str - :keyword digest: The sha256-based digest of the image manifest. - :paramtype digest: str - """ - super().__init__(**kwargs) - self.registry = registry - self.repository = repository - self.tag = tag - self.digest = digest - - -class ImageUpdateTrigger(_serialization.Model): - """The image update trigger that caused a build. - - :ivar id: The unique ID of the trigger. - :vartype id: str - :ivar timestamp: The timestamp when the image update happened. - :vartype timestamp: ~datetime.datetime - :ivar images: The list of image updates that caused the build. - :vartype images: list[~azure.mgmt.containerregistry.v2018_09_01.models.ImageDescriptor] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "images": {"key": "images", "type": "[ImageDescriptor]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - timestamp: Optional[datetime.datetime] = None, - images: Optional[List["_models.ImageDescriptor"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The unique ID of the trigger. - :paramtype id: str - :keyword timestamp: The timestamp when the image update happened. - :paramtype timestamp: ~datetime.datetime - :keyword images: The list of image updates that caused the build. - :paramtype images: list[~azure.mgmt.containerregistry.v2018_09_01.models.ImageDescriptor] - """ - super().__init__(**kwargs) - self.id = id - self.timestamp = timestamp - self.images = images - - -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 server. - - :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. 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. Known values are: "v6", "v7", and "v8". - :vartype variant: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Variant - """ - - _validation = { - "os": {"required": True}, - } - - _attribute_map = { - "os": {"key": "os", "type": "str"}, - "architecture": {"key": "architecture", "type": "str"}, - "variant": {"key": "variant", "type": "str"}, - } - - def __init__( - self, - *, - os: Union[str, "_models.OS"], - architecture: Optional[Union[str, "_models.Architecture"]] = None, - variant: Optional[Union[str, "_models.Variant"]] = None, - **kwargs: Any - ) -> None: - """ - :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. 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. Known values are: "v6", "v7", and "v8". - :paramtype variant: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Variant - """ - super().__init__(**kwargs) - self.os = os - self.architecture = architecture - self.variant = variant - - -class PlatformUpdateParameters(_serialization.Model): - """The properties for updating the platform configuration. - - :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. 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. 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"}, - } - - def __init__( - self, - *, - os: Optional[Union[str, "_models.OS"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - variant: Optional[Union[str, "_models.Variant"]] = None, - **kwargs: Any - ) -> None: - """ - :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. 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. Known values are: "v6", "v7", and "v8". - :paramtype variant: str or ~azure.mgmt.containerregistry.v2018_09_01.models.Variant - """ - super().__init__(**kwargs) - self.os = os - self.architecture = architecture - self.variant = variant - - -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 - """ - - _validation = { - "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"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -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 server. - - :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] - """ - - _validation = { - "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}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :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 - - -class Run(ProxyResource): - """Run resource properties. - - 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 run_id: The unique identifier for the run. - :vartype run_id: str - :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. 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 - :ivar start_time: The time the run started. - :vartype start_time: ~datetime.datetime - :ivar finish_time: The time the run finished. - :vartype finish_time: ~datetime.datetime - :ivar output_images: The list of all images that were generated from the run. This is - applicable if the run generates base image dependencies. - :vartype output_images: list[~azure.mgmt.containerregistry.v2018_09_01.models.ImageDescriptor] - :ivar task: The task against which run was scheduled. - :vartype task: str - :ivar image_update_trigger: The image update trigger that caused the run. This is applicable if - the task has base image trigger configured. - :vartype image_update_trigger: - ~azure.mgmt.containerregistry.v2018_09_01.models.ImageUpdateTrigger - :ivar source_trigger: The source trigger that caused the run. - :vartype source_trigger: - ~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerDescriptor - :ivar platform: The platform properties against which the run will 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 source_registry_auth: The scope of the credentials that were used to login to the source - registry during this run. - :vartype source_registry_auth: str - :ivar custom_registries: The list of custom registries that were logged in during this run. - :vartype custom_registries: list[str] - :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. 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. - :vartype is_archive_enabled: bool - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - run_id: Optional[str] = None, - status: Optional[Union[str, "_models.RunStatus"]] = None, - last_updated_time: Optional[datetime.datetime] = 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["_models.ImageDescriptor"]] = None, - task: Optional[str] = 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, "_models.ProvisioningState"]] = None, - is_archive_enabled: bool = False, - **kwargs: Any - ) -> None: - """ - :keyword run_id: The unique identifier for the run. - :paramtype run_id: str - :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. 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 - :keyword start_time: The time the run started. - :paramtype start_time: ~datetime.datetime - :keyword finish_time: The time the run finished. - :paramtype finish_time: ~datetime.datetime - :keyword output_images: The list of all images that were generated from the run. This is - applicable if the run generates base image dependencies. - :paramtype output_images: - list[~azure.mgmt.containerregistry.v2018_09_01.models.ImageDescriptor] - :keyword task: The task against which run was scheduled. - :paramtype task: str - :keyword image_update_trigger: The image update trigger that caused the run. This is applicable - if the task has base image trigger configured. - :paramtype image_update_trigger: - ~azure.mgmt.containerregistry.v2018_09_01.models.ImageUpdateTrigger - :keyword source_trigger: The source trigger that caused the run. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerDescriptor - :keyword platform: The platform properties against which the run will happen. - :paramtype platform: ~azure.mgmt.containerregistry.v2018_09_01.models.PlatformProperties - :keyword agent_configuration: The machine configuration of the run agent. - :paramtype agent_configuration: - ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties - :keyword source_registry_auth: The scope of the credentials that were used to login to the - source registry during this run. - :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. 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().__init__(**kwargs) - self.run_id = run_id - self.status = status - self.last_updated_time = last_updated_time - self.run_type = run_type - self.create_time = create_time - self.start_time = start_time - self.finish_time = finish_time - self.output_images = output_images - self.task = task - self.image_update_trigger = image_update_trigger - self.source_trigger = source_trigger - self.platform = platform - self.agent_configuration = agent_configuration - self.source_registry_auth = source_registry_auth - self.custom_registries = custom_registries - self.run_error_message = None - self.provisioning_state = provisioning_state - self.is_archive_enabled = is_archive_enabled - - -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. 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. 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 - :ivar finish_time: The time the run finished. - :vartype finish_time: ~datetime.datetime - :ivar output_image_manifests: The list of comma-separated image manifests that were generated - from the run. This is applicable if the run is of - build type. - :vartype output_image_manifests: str - :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. - :vartype is_archive_enabled: bool - :ivar task_name: The name of the task that the run corresponds to. - :vartype task_name: str - """ - - _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"}, - } - - def __init__( - self, - *, - run_id: Optional[str] = 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, - is_archive_enabled: Optional[bool] = None, - task_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword run_id: The unique identifier for the run. - :paramtype run_id: str - :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. 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 - :keyword finish_time: The time the run finished. - :paramtype finish_time: ~datetime.datetime - :keyword output_image_manifests: The list of comma-separated image manifests that were - generated from the run. This is applicable if the run is of - build type. - :paramtype output_image_manifests: str - :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. - :paramtype is_archive_enabled: bool - :keyword task_name: The name of the task that the run corresponds to. - :paramtype task_name: str - """ - super().__init__(**kwargs) - self.run_id = run_id - self.run_type = run_type - self.status = status - self.create_time = create_time - self.finish_time = finish_time - self.output_image_manifests = output_image_manifests - self.is_archive_enabled = is_archive_enabled - self.task_name = task_name - - -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. - :vartype log_link: str - """ - - _attribute_map = { - "log_link": {"key": "logLink", "type": "str"}, - } - - def __init__(self, *, log_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword log_link: The link to logs for a run on a azure container registry. - :paramtype log_link: str - """ - super().__init__(**kwargs) - self.log_link = log_link - - -class RunListResult(_serialization.Model): - """Collection of runs. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.containerregistry.v2018_09_01.models.Run] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Run]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Run"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -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. - :vartype is_archive_enabled: bool - """ - - _attribute_map = { - "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, - } - - def __init__(self, *, is_archive_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. - :paramtype is_archive_enabled: bool - """ - super().__init__(**kwargs) - self.is_archive_enabled = is_archive_enabled - - -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 - based on the type of the secret object. If the type is Opaque, the value will be - used as is without any modification. - :vartype value: str - :ivar type: The type of the secret object which determines how the value of the secret object - has to be - 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"}, - } - - def __init__( - self, - *, - value: Optional[str] = None, - type: Optional[Union[str, "_models.SecretObjectType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The value of the secret. The format of this value will be determined - based on the type of the secret object. If the type is Opaque, the value will be - used as is without any modification. - :paramtype value: str - :keyword type: The type of the secret object which determines how the value of the secret - object has to be - interpreted. "Opaque" - :paramtype type: str or ~azure.mgmt.containerregistry.v2018_09_01.models.SecretObjectType - """ - super().__init__(**kwargs) - self.value = value - self.type = type - - -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 server. - - :ivar name: The name of the overridable value. Required. - :vartype name: str - :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}, - } - - _attribute_map = { - "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: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the overridable value. Required. - :paramtype name: str - :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().__init__(**kwargs) - self.name = name - self.value = value - self.is_secret = is_secret - - -class SourceProperties(_serialization.Model): - """The properties of the source code repository. - - All required parameters must be populated in order to send to server. - - :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: 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 - :ivar source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :vartype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2018_09_01.models.AuthInfo - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - source_control_type: Union[str, "_models.SourceControlType"], - repository_url: str, - branch: Optional[str] = None, - source_control_auth_properties: Optional["_models.AuthInfo"] = None, - **kwargs: Any - ) -> None: - """ - :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: 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 - :keyword source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :paramtype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2018_09_01.models.AuthInfo - """ - 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(_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. 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"}, - } - - def __init__( - self, *, login_mode: Optional[Union[str, "_models.SourceRegistryLoginMode"]] = None, **kwargs: Any - ) -> None: - """ - :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. Known values are: "None" and "Default". - :paramtype login_mode: str or - ~azure.mgmt.containerregistry.v2018_09_01.models.SourceRegistryLoginMode - """ - super().__init__(**kwargs) - self.login_mode = login_mode - - -class SourceTrigger(_serialization.Model): - """The properties of a source based trigger. - - All required parameters must be populated in order to send to server. - - :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: 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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - source_repository: "_models.SourceProperties", - source_trigger_events: List[Union[str, "_models.SourceTriggerEvent"]], - name: str, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :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: 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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.source_repository = source_repository - self.source_trigger_events = source_trigger_events - self.status = status - self.name = name - - -class SourceTriggerDescriptor(_serialization.Model): - """The source trigger that caused a run. - - :ivar id: The unique ID of the trigger. - :vartype id: str - :ivar event_type: The event type of the trigger. - :vartype event_type: str - :ivar commit_id: The unique ID that identifies a commit. - :vartype commit_id: str - :ivar pull_request_id: The unique ID that identifies pull request. - :vartype pull_request_id: str - :ivar repository_url: The repository URL. - :vartype repository_url: str - :ivar branch_name: The branch name in the repository. - :vartype branch_name: str - :ivar provider_type: The source control provider type. - :vartype provider_type: str - """ - - _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"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - event_type: Optional[str] = None, - commit_id: Optional[str] = None, - pull_request_id: Optional[str] = None, - repository_url: Optional[str] = None, - branch_name: Optional[str] = None, - provider_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The unique ID of the trigger. - :paramtype id: str - :keyword event_type: The event type of the trigger. - :paramtype event_type: str - :keyword commit_id: The unique ID that identifies a commit. - :paramtype commit_id: str - :keyword pull_request_id: The unique ID that identifies pull request. - :paramtype pull_request_id: str - :keyword repository_url: The repository URL. - :paramtype repository_url: str - :keyword branch_name: The branch name in the repository. - :paramtype branch_name: str - :keyword provider_type: The source control provider type. - :paramtype provider_type: str - """ - super().__init__(**kwargs) - self.id = id - self.event_type = event_type - self.commit_id = commit_id - self.pull_request_id = pull_request_id - self.repository_url = repository_url - self.branch_name = branch_name - self.provider_type = provider_type - - -class SourceTriggerUpdateParameters(_serialization.Model): - """The properties for updating a source based trigger. - - All required parameters must be populated in order to send to server. - - :ivar source_repository: The properties that describes the source(code) for the task. - :vartype source_repository: - ~azure.mgmt.containerregistry.v2018_09_01.models.SourceUpdateParameters - :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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - name: str, - source_repository: Optional["_models.SourceUpdateParameters"] = None, - source_trigger_events: Optional[List[Union[str, "_models.SourceTriggerEvent"]]] = None, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_repository: The properties that describes the source(code) for the task. - :paramtype source_repository: - ~azure.mgmt.containerregistry.v2018_09_01.models.SourceUpdateParameters - :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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.source_repository = source_repository - self.source_trigger_events = source_trigger_events - self.status = status - self.name = name - - -class SourceUpdateParameters(_serialization.Model): - """The properties for updating the source code repository. - - :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. - :vartype repository_url: str - :ivar branch: The branch name of the source code. - :vartype branch: str - :ivar source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :vartype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2018_09_01.models.AuthInfoUpdateParameters - """ - - _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"}, - } - - def __init__( - self, - *, - source_control_type: Optional[Union[str, "_models.SourceControlType"]] = None, - repository_url: Optional[str] = None, - branch: Optional[str] = None, - source_control_auth_properties: Optional["_models.AuthInfoUpdateParameters"] = None, - **kwargs: Any - ) -> None: - """ - :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. - :paramtype repository_url: str - :keyword branch: The branch name of the source code. - :paramtype branch: str - :keyword source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :paramtype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2018_09_01.models.AuthInfoUpdateParameters - """ - 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(_serialization.Model): - """The properties of a response to source upload request. - - :ivar upload_url: The URL where the client can upload the source. - :vartype upload_url: str - :ivar relative_path: The relative path to the source. This is used to submit the subsequent - queue build request. - :vartype relative_path: str - """ - - _attribute_map = { - "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: Any) -> None: - """ - :keyword upload_url: The URL where the client can upload the source. - :paramtype upload_url: str - :keyword relative_path: The relative path to the source. This is used to submit the subsequent - queue build request. - :paramtype relative_path: str - """ - 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 server. - - :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}, - } - - _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"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = 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: Any - ) -> None: - """ - :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 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 - :keyword agent_configuration: The machine configuration of the run agent. - :paramtype agent_configuration: - ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :keyword step: The properties of a task step. - :paramtype step: ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStepProperties - :keyword trigger: The properties that describe all triggers for the task. - :paramtype trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerProperties - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials - """ - super().__init__(location=location, tags=tags, **kwargs) - self.provisioning_state = None - self.creation_date = None - self.status = status - self.platform = platform - self.agent_configuration = agent_configuration - self.timeout = timeout - self.step = step - self.trigger = trigger - self.credentials = credentials - - -class TaskListResult(_serialization.Model): - """The collection of tasks. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.containerregistry.v2018_09_01.models.Task] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Task]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Task"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class TaskRunRequest(RunRequest): - """The parameters for a task run request. - - 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 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: 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}, - } - - _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]"}, - } - - def __init__( - self, - *, - task_name: str, - is_archive_enabled: bool = False, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :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: 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().__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type: str = "TaskRunRequest" - self.task_name = task_name - self.values = values - - -class TaskUpdateParameters(_serialization.Model): - """The parameters for updating a task. - - :ivar tags: The ARM resource tags. - :vartype tags: dict[str, str] - :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 - :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 for updating a task step. - :vartype step: ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStepUpdateParameters - :ivar trigger: The properties for updating trigger properties. - :vartype trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerUpdateParameters - :ivar credentials: The parameters 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 - """ - - _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"}, - } - - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = 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["_models.TaskStepUpdateParameters"] = None, - trigger: Optional["_models.TriggerUpdateParameters"] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :keyword tags: The ARM resource tags. - :paramtype tags: dict[str, str] - :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 - :keyword agent_configuration: The machine configuration of the run agent. - :paramtype agent_configuration: - ~azure.mgmt.containerregistry.v2018_09_01.models.AgentProperties - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :keyword step: The properties for updating a task step. - :paramtype step: ~azure.mgmt.containerregistry.v2018_09_01.models.TaskStepUpdateParameters - :keyword trigger: The properties for updating trigger properties. - :paramtype trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.TriggerUpdateParameters - :keyword credentials: The parameters that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2018_09_01.models.Credentials - """ - super().__init__(**kwargs) - self.tags = tags - self.status = status - self.platform = platform - self.agent_configuration = agent_configuration - self.timeout = timeout - self.step = step - self.trigger = trigger - self.credentials = credentials - - -class TriggerProperties(_serialization.Model): - """The properties of a trigger. - - :ivar source_triggers: The collection of triggers based on source code repository. - :vartype source_triggers: list[~azure.mgmt.containerregistry.v2018_09_01.models.SourceTrigger] - :ivar base_image_trigger: The trigger based on base image dependencies. - :vartype base_image_trigger: ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTrigger - """ - - _attribute_map = { - "source_triggers": {"key": "sourceTriggers", "type": "[SourceTrigger]"}, - "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTrigger"}, - } - - def __init__( - self, - *, - source_triggers: Optional[List["_models.SourceTrigger"]] = None, - base_image_trigger: Optional["_models.BaseImageTrigger"] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_triggers: The collection of triggers based on source code repository. - :paramtype source_triggers: - list[~azure.mgmt.containerregistry.v2018_09_01.models.SourceTrigger] - :keyword base_image_trigger: The trigger based on base image dependencies. - :paramtype base_image_trigger: - ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTrigger - """ - super().__init__(**kwargs) - self.source_triggers = source_triggers - self.base_image_trigger = base_image_trigger - - -class TriggerUpdateParameters(_serialization.Model): - """The properties for updating triggers. - - :ivar source_triggers: The collection of triggers based on source code repository. - :vartype source_triggers: - list[~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerUpdateParameters] - :ivar base_image_trigger: The trigger based on base image dependencies. - :vartype base_image_trigger: - ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTriggerUpdateParameters - """ - - _attribute_map = { - "source_triggers": {"key": "sourceTriggers", "type": "[SourceTriggerUpdateParameters]"}, - "base_image_trigger": {"key": "baseImageTrigger", "type": "BaseImageTriggerUpdateParameters"}, - } - - def __init__( - self, - *, - source_triggers: Optional[List["_models.SourceTriggerUpdateParameters"]] = None, - base_image_trigger: Optional["_models.BaseImageTriggerUpdateParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_triggers: The collection of triggers based on source code repository. - :paramtype source_triggers: - list[~azure.mgmt.containerregistry.v2018_09_01.models.SourceTriggerUpdateParameters] - :keyword base_image_trigger: The trigger based on base image dependencies. - :paramtype base_image_trigger: - ~azure.mgmt.containerregistry.v2018_09_01.models.BaseImageTriggerUpdateParameters - """ - 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index d57838606437..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._runs_operations import RunsOperations # type: ignore -from ._tasks_operations import TasksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "RunsOperations", - "TasksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 2199f62ce46e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_registries_operations.py +++ /dev/null @@ -1,375 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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") - - # Construct URL - _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]*$" - ), - } - - _url: str = _url.format(**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_get_build_source_upload_url_request( # pylint: disable=name-too-long - 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: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: Union[_models.RunRequest, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_request, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: _models.RunRequest, - *, - 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: ~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 - :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_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RunRequest - type or a IO[bytes] type. Required. - :type run_request: ~azure.mgmt.containerregistry.v2018_09_01.models.RunRequest or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_request=run_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Run](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_build_source_upload_url( - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: SourceUploadDefinition or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.SourceUploadDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - - _request = build_get_build_source_upload_url_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 017b3b868453..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_runs_operations.py +++ /dev/null @@ -1,763 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - - # 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, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_update_request( - resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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") - - # Construct URL - _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"), - } - - _url: str = _url.format(**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_get_log_sas_url_request( - resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_cancel_request( - resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> 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. Required. - :type resource_group_name: str - :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', - 'Has', 'All' are allowed. Default value is None. - :type filter: str - :param top: $top is supported for get list of runs, which limits the maximum number of runs to - return. Default value is None. - :type top: int - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - 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. 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 - :return: Run or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Run - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.Run] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **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. Is either a RunUpdateParameters type - or a IO[bytes] type. Required. - :type run_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.RunUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_id=run_id, - run_update_parameters=run_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Run](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_log_sas_url( - 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. 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 - :return: RunGetLogResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.RunGetLogResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - - _request = build_get_log_sas_url_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _cancel_initial( - self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - run_id=run_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index d7eed358a5b9..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/operations/_tasks_operations.py +++ /dev/null @@ -1,988 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, task_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: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, task_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: str = 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") - - # Construct URL - _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-_]*$" - ), - } - - _url: str = _url.format(**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, task_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, task_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: str = 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") - - # Construct URL - _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-_]*$" - ), - } - - _url: str = _url.format(**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_get_details_request( - resource_group_name: str, registry_name: str, task_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: str = kwargs.pop("api_version", _params.pop("api-version", "2018-09-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_create_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **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. Is either a Task type or a - IO[bytes] type. Required. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2018_09_01.models.Task or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_create_parameters=task_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - task_name=task_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **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. Is either a - TaskUpdateParameters type or a IO[bytes] type. Required. - :type task_update_parameters: - ~azure.mgmt.containerregistry.v2018_09_01.models.TaskUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_update_parameters=task_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2018_09_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2018-09-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_details_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2018_09_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 731d0450dc18..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2019-04-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index 36aaeb427c83..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_container_registry_management_client.py +++ /dev/null @@ -1,119 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import RegistriesOperations, RunsOperations, TasksOperations - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: azure.mgmt.containerregistry.v2019_04_01.operations.RegistriesOperations - :ivar runs: RunsOperations operations - :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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "2019-04-01" - ) - self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize, "2019-04-01") - self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize, "2019-04-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index 34aa5ca74bdb..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2019-04-01", - "total_api_version_list": ["2019-04-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "registries": "RegistriesOperations", - "runs": "RunsOperations", - "tasks": "TasksOperations" - } -} 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 4f141ae7bcf3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2019-04-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index 3308e8edf140..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_container_registry_management_client.py +++ /dev/null @@ -1,122 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import RegistriesOperations, RunsOperations, TasksOperations - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2019_04_01.aio.operations.RegistriesOperations - :ivar runs: RunsOperations operations - :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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "2019-04-01" - ) - self.runs = RunsOperations(self._client, self._config, self._serialize, self._deserialize, "2019-04-01") - self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize, "2019-04-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index d57838606437..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._runs_operations import RunsOperations # type: ignore -from ._tasks_operations import TasksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "RunsOperations", - "TasksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index eeba7892874d..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_registries_operations.py +++ /dev/null @@ -1,308 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._registries_operations import build_get_build_source_upload_url_request, build_schedule_run_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_04_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: Union[_models.RunRequest, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_request, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: _models.RunRequest, - *, - 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: ~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 - :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_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RunRequest - type or a IO[bytes] type. Required. - :type run_request: ~azure.mgmt.containerregistry.v2019_04_01.models.RunRequest or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_request=run_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Run]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_build_source_upload_url( - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: SourceUploadDefinition or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.SourceUploadDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - - _request = build_get_build_source_upload_url_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 02f7aacb52d6..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_runs_operations.py +++ /dev/null @@ -1,599 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class RunsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> 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. Required. - :type resource_group_name: str - :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', - 'Has', 'All' are allowed. Default value is None. - :type filter: str - :param top: $top is supported for get list of runs, which limits the maximum number of runs to - return. Default value is None. - :type top: int - :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.Run] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace_async - 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. 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 - :return: Run or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Run - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.Run] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **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. Is either a RunUpdateParameters type - or a IO[bytes] type. Required. - :type run_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_id=run_id, - run_update_parameters=run_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Run]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async def get_log_sas_url( - 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. 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 - :return: RunGetLogResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.RunGetLogResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - - _request = build_get_log_sas_url_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _cancel_initial( - self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - run_id=run_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 275e2df1202f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/aio/operations/_tasks_operations.py +++ /dev/null @@ -1,789 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class TasksOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Task] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace_async - 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_create_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **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. Is either a Task type or a - IO[bytes] type. Required. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_create_parameters=task_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - task_name=task_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **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. Is either a - TaskUpdateParameters type or a IO[bytes] type. Required. - :type task_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_update_parameters=task_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace_async - async 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_details_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 2f58be71af7a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/__init__.py +++ /dev/null @@ -1,166 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - Architecture, - BaseImageDependencyType, - BaseImageTriggerType, - OS, - ProvisioningState, - ResourceIdentityType, - RunStatus, - RunType, - SecretObjectType, - SourceControlType, - SourceRegistryLoginMode, - SourceTriggerEvent, - StepType, - TaskStatus, - TokenType, - TriggerStatus, - Variant, -) -from ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index ec24791fa1a7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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 Architecture(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The OS architecture.""" - - AMD64 = "amd64" - X86 = "x86" - ARM = "arm" - - -class BaseImageDependencyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the base image dependency.""" - - BUILD_TIME = "BuildTime" - RUN_TIME = "RunTime" - - -class BaseImageTriggerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the auto trigger for base image dependency updates.""" - - ALL = "All" - RUNTIME = "Runtime" - - -class OS(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The operating system type required for the run.""" - - WINDOWS = "Windows" - LINUX = "Linux" - - -class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioning state of a run.""" - - CREATING = "Creating" - UPDATING = "Updating" - DELETING = "Deleting" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - - -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(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current status of the run.""" - - QUEUED = "Queued" - STARTED = "Started" - RUNNING = "Running" - SUCCEEDED = "Succeeded" - FAILED = "Failed" - CANCELED = "Canceled" - ERROR = "Error" - TIMEOUT = "Timeout" - - -class RunType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of run.""" - - QUICK_BUILD = "QuickBuild" - QUICK_RUN = "QuickRun" - AUTO_BUILD = "AutoBuild" - AUTO_RUN = "AutoRun" - - -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" - VAULTSECRET = "Vaultsecret" - - -class SourceControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of source control service.""" - - GITHUB = "Github" - VISUAL_STUDIO_TEAM_SERVICE = "VisualStudioTeamService" - - -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 - the source registry during the run. - """ - - NONE = "None" - DEFAULT = "Default" - - -class SourceTriggerEvent(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SourceTriggerEvent.""" - - COMMIT = "commit" - PULLREQUEST = "pullrequest" - - -class StepType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the step.""" - - DOCKER = "Docker" - FILE_TASK = "FileTask" - ENCODED_TASK = "EncodedTask" - - -class TaskStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current status of task.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class TokenType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of Auth token.""" - - PAT = "PAT" - O_AUTH = "OAuth" - - -class TriggerStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current status of trigger.""" - - DISABLED = "Disabled" - ENABLED = "Enabled" - - -class Variant(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Variant of the CPU.""" - - V6 = "v6" - V7 = "v7" - V8 = "v8" 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 deleted file mode 100644 index 41a46a153861..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_models_py3.py +++ /dev/null @@ -1,2996 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -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. - :vartype cpu: int - """ - - _attribute_map = { - "cpu": {"key": "cpu", "type": "int"}, - } - - def __init__(self, *, cpu: Optional[int] = None, **kwargs: Any) -> None: - """ - :keyword cpu: The CPU configuration in terms of number of cores required for the run. - :paramtype cpu: int - """ - super().__init__(**kwargs) - self.cpu = cpu - - -class Argument(_serialization.Model): - """The properties of a run argument. - - All required parameters must be populated in order to send to server. - - :ivar name: The name of the argument. Required. - :vartype name: str - :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. - :vartype is_secret: bool - """ - - _validation = { - "name": {"required": True}, - "value": {"required": True}, - } - - _attribute_map = { - "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: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the argument. Required. - :paramtype name: str - :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().__init__(**kwargs) - self.name = name - self.value = value - self.is_secret = is_secret - - -class AuthInfo(_serialization.Model): - """The authorization properties for accessing the source code repository. - - All required parameters must be populated in order to send to server. - - :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: 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 - :ivar scope: The scope of the access token. - :vartype scope: str - :ivar expires_in: Time in seconds that the token remains valid. - :vartype expires_in: int - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - token_type: Union[str, "_models.TokenType"], - token: str, - refresh_token: Optional[str] = None, - scope: Optional[str] = None, - expires_in: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :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: 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 - :keyword scope: The scope of the access token. - :paramtype scope: str - :keyword expires_in: Time in seconds that the token remains valid. - :paramtype expires_in: int - """ - super().__init__(**kwargs) - self.token_type = token_type - self.token = token - self.refresh_token = refresh_token - self.scope = scope - self.expires_in = expires_in - - -class AuthInfoUpdateParameters(_serialization.Model): - """The authorization properties for accessing the source code repository. - - :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 - :ivar refresh_token: The refresh token used to refresh the access token. - :vartype refresh_token: str - :ivar scope: The scope of the access token. - :vartype scope: str - :ivar expires_in: Time in seconds that the token remains valid. - :vartype expires_in: int - """ - - _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"}, - } - - def __init__( - self, - *, - token_type: Optional[Union[str, "_models.TokenType"]] = None, - token: Optional[str] = None, - refresh_token: Optional[str] = None, - scope: Optional[str] = None, - expires_in: Optional[int] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword refresh_token: The refresh token used to refresh the access token. - :paramtype refresh_token: str - :keyword scope: The scope of the access token. - :paramtype scope: str - :keyword expires_in: Time in seconds that the token remains valid. - :paramtype expires_in: int - """ - super().__init__(**kwargs) - self.token_type = token_type - self.token = token - self.refresh_token = refresh_token - self.scope = scope - self.expires_in = expires_in - - -class BaseImageDependency(_serialization.Model): - """Properties that describe a base image dependency. - - :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 - :ivar repository: The repository name. - :vartype repository: str - :ivar tag: The tag name. - :vartype tag: str - :ivar digest: The sha256-based digest of the image manifest. - :vartype digest: str - """ - - _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"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.BaseImageDependencyType"]] = None, - registry: Optional[str] = None, - repository: Optional[str] = None, - tag: Optional[str] = None, - digest: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :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 - :keyword registry: The registry login server. - :paramtype registry: str - :keyword repository: The repository name. - :paramtype repository: str - :keyword tag: The tag name. - :paramtype tag: str - :keyword digest: The sha256-based digest of the image manifest. - :paramtype digest: str - """ - super().__init__(**kwargs) - self.type = type - self.registry = registry - self.repository = repository - self.tag = tag - self.digest = digest - - -class BaseImageTrigger(_serialization.Model): - """The trigger based on base image dependency. - - All required parameters must be populated in order to send to server. - - :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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - base_image_trigger_type: Union[str, "_models.BaseImageTriggerType"], - name: str, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.base_image_trigger_type = base_image_trigger_type - self.status = status - self.name = name - - -class BaseImageTriggerUpdateParameters(_serialization.Model): - """The properties for updating base image dependency trigger. - - All required parameters must be populated in order to send to server. - - :ivar base_image_trigger_type: The type of the auto trigger for base image dependency updates. - 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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "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, "_models.BaseImageTriggerType"]] = None, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword base_image_trigger_type: The type of the auto trigger for base image dependency - 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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.base_image_trigger_type = base_image_trigger_type - self.status = status - self.name = name - - -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. - :vartype source_registry: - ~azure.mgmt.containerregistry.v2019_04_01.models.SourceRegistryCredentials - :ivar custom_registries: Describes the credential parameters for accessing other custom - registries. The key - for the dictionary item will be the registry login server (myregistry.azurecr.io) and - the value of the item will be the registry credentials for accessing the registry. - :vartype custom_registries: dict[str, - ~azure.mgmt.containerregistry.v2019_04_01.models.CustomRegistryCredentials] - """ - - _attribute_map = { - "source_registry": {"key": "sourceRegistry", "type": "SourceRegistryCredentials"}, - "custom_registries": {"key": "customRegistries", "type": "{CustomRegistryCredentials}"}, - } - - def __init__( - self, - *, - source_registry: Optional["_models.SourceRegistryCredentials"] = None, - custom_registries: Optional[Dict[str, "_models.CustomRegistryCredentials"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_registry: Describes the credential parameters for accessing the source - registry. - :paramtype source_registry: - ~azure.mgmt.containerregistry.v2019_04_01.models.SourceRegistryCredentials - :keyword custom_registries: Describes the credential parameters for accessing other custom - registries. The key - for the dictionary item will be the registry login server (myregistry.azurecr.io) and - the value of the item will be the registry credentials for accessing the registry. - :paramtype custom_registries: dict[str, - ~azure.mgmt.containerregistry.v2019_04_01.models.CustomRegistryCredentials] - """ - super().__init__(**kwargs) - self.source_registry = source_registry - self.custom_registries = custom_registries - - -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. - :vartype user_name: ~azure.mgmt.containerregistry.v2019_04_01.models.SecretObject - :ivar password: The password for logging into the custom registry. The password is a secret - object that allows multiple ways of providing the value for it. - :vartype password: ~azure.mgmt.containerregistry.v2019_04_01.models.SecretObject - :ivar identity: Indicates the managed identity assigned to the custom credential. If a - user-assigned identity - this value is the Client ID. If a system-assigned identity, the value will be ``system``. In - the case of a system-assigned identity, the Client ID will be determined by the runner. This - identity may be used to authenticate to key vault to retrieve credentials or it may be the - only - source of authentication used for accessing the registry. - :vartype identity: str - """ - - _attribute_map = { - "user_name": {"key": "userName", "type": "SecretObject"}, - "password": {"key": "password", "type": "SecretObject"}, - "identity": {"key": "identity", "type": "str"}, - } - - def __init__( - self, - *, - user_name: Optional["_models.SecretObject"] = None, - password: Optional["_models.SecretObject"] = None, - identity: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword user_name: The username for logging into the custom registry. - :paramtype user_name: ~azure.mgmt.containerregistry.v2019_04_01.models.SecretObject - :keyword password: The password for logging into the custom registry. The password is a secret - object that allows multiple ways of providing the value for it. - :paramtype password: ~azure.mgmt.containerregistry.v2019_04_01.models.SecretObject - :keyword identity: Indicates the managed identity assigned to the custom credential. If a - user-assigned identity - this value is the Client ID. If a system-assigned identity, the value will be ``system``. In - the case of a system-assigned identity, the Client ID will be determined by the runner. This - identity may be used to authenticate to key vault to retrieve credentials or it may be the - only - source of authentication used for accessing the registry. - :paramtype identity: str - """ - super().__init__(**kwargs) - self.user_name = user_name - self.password = password - self.identity = identity - - -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 - - All required parameters must be populated in order to send to 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 - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, - } - - _subtype_map = { - "type": { - "DockerBuildRequest": "DockerBuildRequest", - "EncodedTaskRunRequest": "EncodedTaskRunRequest", - "FileTaskRunRequest": "FileTaskRunRequest", - "TaskRunRequest": "TaskRunRequest", - } - } - - def __init__(self, *, is_archive_enabled: bool = False, **kwargs: Any) -> None: - """ - :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run - or not. - :paramtype is_archive_enabled: bool - """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.is_archive_enabled = is_archive_enabled - - -class DockerBuildRequest(RunRequest): - """The parameters for a docker quick build. - - All required parameters must be populated in order to send to 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 image_names: The fully qualified image names including the repository and tag. - :vartype image_names: list[str] - :ivar is_push_enabled: The value of this property indicates whether the image built should be - pushed to the registry or not. - :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: 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 - :ivar arguments: The collection of override arguments to be used when executing the run. - :vartype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :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 - :ivar source_location: The URL(absolute or relative) of the source context. It can be an URL to - a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :vartype source_location: str - :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 = { - "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"}, - } - - def __init__( - self, - *, - docker_file_path: str, - platform: "_models.PlatformProperties", - is_archive_enabled: bool = False, - image_names: Optional[List[str]] = None, - is_push_enabled: bool = True, - no_cache: bool = False, - target: Optional[str] = None, - arguments: Optional[List["_models.Argument"]] = None, - timeout: int = 3600, - agent_configuration: Optional["_models.AgentProperties"] = None, - source_location: Optional[str] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :keyword is_archive_enabled: The value that indicates whether archiving is enabled for the run - or not. - :paramtype is_archive_enabled: bool - :keyword image_names: The fully qualified image names including the repository and tag. - :paramtype image_names: list[str] - :keyword is_push_enabled: The value of this property indicates whether the image built should - be pushed to the registry or not. - :paramtype is_push_enabled: bool - :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: 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 - :keyword arguments: The collection of override arguments to be used when executing the run. - :paramtype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :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: - ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties - :keyword source_location: The URL(absolute or relative) of the source context. It can be an URL - to a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :paramtype source_location: str - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials - """ - 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 - self.docker_file_path = docker_file_path - self.target = target - self.arguments = arguments - self.timeout = timeout - self.platform = platform - self.agent_configuration = agent_configuration - self.source_location = source_location - self.credentials = credentials - - -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 - - 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 server. - - :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: - list[~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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 - """ - - _validation = { - "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"}, - } - - _subtype_map = {"type": {"Docker": "DockerBuildStep", "EncodedTask": "EncodedTaskStep", "FileTask": "FileTaskStep"}} - - def __init__( - self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 - """ - 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 - - -class DockerBuildStep(TaskStepProperties): - """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 server. - - :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: - list[~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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 image_names: The fully qualified image names including the repository and tag. - :vartype image_names: list[str] - :ivar is_push_enabled: The value of this property indicates whether the image built should be - pushed to the registry or not. - :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: 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 - :ivar arguments: The collection of override arguments to be used when executing this build - step. - :vartype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] - """ - - _validation = { - "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]"}, - } - - def __init__( - self, - *, - docker_file_path: str, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - image_names: Optional[List[str]] = None, - is_push_enabled: bool = True, - no_cache: bool = False, - target: Optional[str] = None, - arguments: Optional[List["_models.Argument"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 image_names: The fully qualified image names including the repository and tag. - :paramtype image_names: list[str] - :keyword is_push_enabled: The value of this property indicates whether the image built should - be pushed to the registry or not. - :paramtype is_push_enabled: bool - :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: 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 - :keyword arguments: The collection of override arguments to be used when executing this build - step. - :paramtype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] - """ - 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 - self.docker_file_path = docker_file_path - self.target = target - self.arguments = arguments - - -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 - - All required parameters must be populated in order to send to server. - - :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 - :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 - """ - - _validation = { - "type": {"required": True}, - } - - _attribute_map = { - "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", - } - } - - def __init__( - self, *, context_path: Optional[str] = None, context_access_token: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 - """ - super().__init__(**kwargs) - self.type: Optional[str] = None - self.context_path = context_path - self.context_access_token = context_access_token - - -class DockerBuildStepUpdateParameters(TaskStepUpdateParameters): - """The properties for updating a docker build step. - - All required parameters must be populated in order to send to server. - - :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 - :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 image_names: The fully qualified image names including the repository and tag. - :vartype image_names: list[str] - :ivar is_push_enabled: The value of this property indicates whether the image built should be - pushed to the registry or not. - :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: The Docker file path relative to the source context. - :vartype docker_file_path: str - :ivar arguments: The collection of override arguments to be used when executing this build - step. - :vartype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] - :ivar target: The name of the target build stage for the docker build. - :vartype target: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - image_names: Optional[List[str]] = None, - is_push_enabled: Optional[bool] = None, - no_cache: Optional[bool] = None, - docker_file_path: Optional[str] = None, - arguments: Optional[List["_models.Argument"]] = None, - target: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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 image_names: The fully qualified image names including the repository and tag. - :paramtype image_names: list[str] - :keyword is_push_enabled: The value of this property indicates whether the image built should - be pushed to the registry or not. - :paramtype is_push_enabled: bool - :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: The Docker file path relative to the source context. - :paramtype docker_file_path: str - :keyword arguments: The collection of override arguments to be used when executing this build - step. - :paramtype arguments: list[~azure.mgmt.containerregistry.v2019_04_01.models.Argument] - :keyword target: The name of the target build stage for the docker build. - :paramtype target: 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 - self.docker_file_path = docker_file_path - self.arguments = arguments - self.target = target - - -class EncodedTaskRunRequest(RunRequest): - """The parameters for a quick task run request. - - All required parameters must be populated in order to send to 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: 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 - :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] - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :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 - :ivar source_location: The URL(absolute or relative) of the source context. It can be an URL to - a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :vartype source_location: str - :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 = { - "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"}, - } - - def __init__( - self, - *, - encoded_task_content: str, - platform: "_models.PlatformProperties", - is_archive_enabled: bool = False, - encoded_values_content: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - timeout: int = 3600, - agent_configuration: Optional["_models.AgentProperties"] = None, - source_location: Optional[str] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :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: 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] - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :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: - ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties - :keyword source_location: The URL(absolute or relative) of the source context. It can be an URL - to a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :paramtype source_location: str - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials - """ - 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 - self.timeout = timeout - self.platform = platform - self.agent_configuration = agent_configuration - self.source_location = source_location - self.credentials = credentials - - -class EncodedTaskStep(TaskStepProperties): - """The properties of a encoded task 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 server. - - :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: - list[~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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: 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 - :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}, - "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]"}, - } - - def __init__( - self, - *, - encoded_task_content: str, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - encoded_values_content: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: 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().__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 EncodedTaskStepUpdateParameters(TaskStepUpdateParameters): - """The properties for updating encoded task step. - - All required parameters must be populated in order to send to server. - - :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 - :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: Base64 encoded value of the template/definition file content. - :vartype encoded_task_content: str - :ivar encoded_values_content: Base64 encoded value of the parameters/values file content. - :vartype encoded_values_content: 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}, - } - - _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]"}, - } - - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - encoded_task_content: Optional[str] = None, - encoded_values_content: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: Base64 encoded value of the template/definition file content. - :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().__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 FileTaskRunRequest(RunRequest): - """The request parameters for a scheduling run against a task file. - - All required parameters must be populated in order to send to 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: 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 - :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] - :ivar timeout: Run timeout in seconds. - :vartype timeout: int - :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 - :ivar source_location: The URL(absolute or relative) of the source context. It can be an URL to - a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :vartype source_location: str - :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 = { - "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"}, - } - - def __init__( - self, - *, - task_file_path: str, - platform: "_models.PlatformProperties", - is_archive_enabled: bool = False, - values_file_path: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - timeout: int = 3600, - agent_configuration: Optional["_models.AgentProperties"] = None, - source_location: Optional[str] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :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: 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 - :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] - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :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: - ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties - :keyword source_location: The URL(absolute or relative) of the source context. It can be an URL - to a tar or git repository. - If it is relative URL, the relative path should be obtained from calling - listBuildSourceUploadUrl API. - :paramtype source_location: str - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials - """ - 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 - self.timeout = timeout - self.platform = platform - self.agent_configuration = agent_configuration - self.source_location = source_location - self.credentials = credentials - - -class FileTaskStep(TaskStepProperties): - """The properties of a task 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 server. - - :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: - list[~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageDependency] - :ivar context_path: The URL(absolute or relative) of the source context for the task step. - :vartype context_path: str - :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: 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 - :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}, - "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]"}, - } - - def __init__( - self, - *, - task_file_path: str, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - values_file_path: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: 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().__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 FileTaskStepUpdateParameters(TaskStepUpdateParameters): - """The properties of updating a task step. - - All required parameters must be populated in order to send to server. - - :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 - :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: The task template/definition file path relative to the source context. - :vartype task_file_path: str - :ivar values_file_path: The values/parameters file path relative to the source context. - :vartype values_file_path: 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}, - } - - _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]"}, - } - - def __init__( - self, - *, - context_path: Optional[str] = None, - context_access_token: Optional[str] = None, - task_file_path: Optional[str] = None, - values_file_path: Optional[str] = None, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword context_path: The URL(absolute or relative) of the source context for the task step. - :paramtype context_path: str - :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: The task template/definition file path relative to the source context. - :paramtype task_file_path: str - :keyword values_file_path: The 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().__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(_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.v2019_04_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.v2019_04_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: Any - ) -> None: - """ - :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.v2019_04_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.v2019_04_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 ImageDescriptor(_serialization.Model): - """Properties for a registry image. - - :ivar registry: The registry login server. - :vartype registry: str - :ivar repository: The repository name. - :vartype repository: str - :ivar tag: The tag name. - :vartype tag: str - :ivar digest: The sha256-based digest of the image manifest. - :vartype digest: str - """ - - _attribute_map = { - "registry": {"key": "registry", "type": "str"}, - "repository": {"key": "repository", "type": "str"}, - "tag": {"key": "tag", "type": "str"}, - "digest": {"key": "digest", "type": "str"}, - } - - def __init__( - self, - *, - registry: Optional[str] = None, - repository: Optional[str] = None, - tag: Optional[str] = None, - digest: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword registry: The registry login server. - :paramtype registry: str - :keyword repository: The repository name. - :paramtype repository: str - :keyword tag: The tag name. - :paramtype tag: str - :keyword digest: The sha256-based digest of the image manifest. - :paramtype digest: str - """ - super().__init__(**kwargs) - self.registry = registry - self.repository = repository - self.tag = tag - self.digest = digest - - -class ImageUpdateTrigger(_serialization.Model): - """The image update trigger that caused a build. - - :ivar id: The unique ID of the trigger. - :vartype id: str - :ivar timestamp: The timestamp when the image update happened. - :vartype timestamp: ~datetime.datetime - :ivar images: The list of image updates that caused the build. - :vartype images: list[~azure.mgmt.containerregistry.v2019_04_01.models.ImageDescriptor] - """ - - _attribute_map = { - "id": {"key": "id", "type": "str"}, - "timestamp": {"key": "timestamp", "type": "iso-8601"}, - "images": {"key": "images", "type": "[ImageDescriptor]"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - timestamp: Optional[datetime.datetime] = None, - images: Optional[List["_models.ImageDescriptor"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The unique ID of the trigger. - :paramtype id: str - :keyword timestamp: The timestamp when the image update happened. - :paramtype timestamp: ~datetime.datetime - :keyword images: The list of image updates that caused the build. - :paramtype images: list[~azure.mgmt.containerregistry.v2019_04_01.models.ImageDescriptor] - """ - super().__init__(**kwargs) - self.id = id - self.timestamp = timestamp - self.images = images - - -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 server. - - :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. 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. Known values are: "v6", "v7", and "v8". - :vartype variant: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Variant - """ - - _validation = { - "os": {"required": True}, - } - - _attribute_map = { - "os": {"key": "os", "type": "str"}, - "architecture": {"key": "architecture", "type": "str"}, - "variant": {"key": "variant", "type": "str"}, - } - - def __init__( - self, - *, - os: Union[str, "_models.OS"], - architecture: Optional[Union[str, "_models.Architecture"]] = None, - variant: Optional[Union[str, "_models.Variant"]] = None, - **kwargs: Any - ) -> None: - """ - :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. 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. Known values are: "v6", "v7", and "v8". - :paramtype variant: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Variant - """ - super().__init__(**kwargs) - self.os = os - self.architecture = architecture - self.variant = variant - - -class PlatformUpdateParameters(_serialization.Model): - """The properties for updating the platform configuration. - - :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. 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. 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"}, - } - - def __init__( - self, - *, - os: Optional[Union[str, "_models.OS"]] = None, - architecture: Optional[Union[str, "_models.Architecture"]] = None, - variant: Optional[Union[str, "_models.Variant"]] = None, - **kwargs: Any - ) -> None: - """ - :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. 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. Known values are: "v6", "v7", and "v8". - :paramtype variant: str or ~azure.mgmt.containerregistry.v2019_04_01.models.Variant - """ - super().__init__(**kwargs) - self.os = os - self.architecture = architecture - self.variant = variant - - -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 - """ - - _validation = { - "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"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -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 server. - - :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] - """ - - _validation = { - "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}"}, - } - - def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: - """ - :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 - - -class Run(ProxyResource): - """Run resource properties. - - 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 run_id: The unique identifier for the run. - :vartype run_id: str - :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. 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 - :ivar start_time: The time the run started. - :vartype start_time: ~datetime.datetime - :ivar finish_time: The time the run finished. - :vartype finish_time: ~datetime.datetime - :ivar output_images: The list of all images that were generated from the run. This is - applicable if the run generates base image dependencies. - :vartype output_images: list[~azure.mgmt.containerregistry.v2019_04_01.models.ImageDescriptor] - :ivar task: The task against which run was scheduled. - :vartype task: str - :ivar image_update_trigger: The image update trigger that caused the run. This is applicable if - the task has base image trigger configured. - :vartype image_update_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.ImageUpdateTrigger - :ivar source_trigger: The source trigger that caused the run. - :vartype source_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerDescriptor - :ivar platform: The platform properties against which the run will 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 source_registry_auth: The scope of the credentials that were used to login to the source - registry during this run. - :vartype source_registry_auth: str - :ivar custom_registries: The list of custom registries that were logged in during this run. - :vartype custom_registries: list[str] - :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. 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. - :vartype is_archive_enabled: bool - :ivar timer_trigger: The timer trigger that caused the run. - :vartype timer_trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.TimerTriggerDescriptor - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - run_id: Optional[str] = None, - status: Optional[Union[str, "_models.RunStatus"]] = None, - last_updated_time: Optional[datetime.datetime] = 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["_models.ImageDescriptor"]] = None, - task: Optional[str] = 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, "_models.ProvisioningState"]] = None, - is_archive_enabled: bool = False, - timer_trigger: Optional["_models.TimerTriggerDescriptor"] = None, - **kwargs: Any - ) -> None: - """ - :keyword run_id: The unique identifier for the run. - :paramtype run_id: str - :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. 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 - :keyword start_time: The time the run started. - :paramtype start_time: ~datetime.datetime - :keyword finish_time: The time the run finished. - :paramtype finish_time: ~datetime.datetime - :keyword output_images: The list of all images that were generated from the run. This is - applicable if the run generates base image dependencies. - :paramtype output_images: - list[~azure.mgmt.containerregistry.v2019_04_01.models.ImageDescriptor] - :keyword task: The task against which run was scheduled. - :paramtype task: str - :keyword image_update_trigger: The image update trigger that caused the run. This is applicable - if the task has base image trigger configured. - :paramtype image_update_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.ImageUpdateTrigger - :keyword source_trigger: The source trigger that caused the run. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerDescriptor - :keyword platform: The platform properties against which the run will happen. - :paramtype platform: ~azure.mgmt.containerregistry.v2019_04_01.models.PlatformProperties - :keyword agent_configuration: The machine configuration of the run agent. - :paramtype agent_configuration: - ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties - :keyword source_registry_auth: The scope of the credentials that were used to login to the - source registry during this run. - :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. 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. - :paramtype is_archive_enabled: bool - :keyword timer_trigger: The timer trigger that caused the run. - :paramtype timer_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.TimerTriggerDescriptor - """ - super().__init__(**kwargs) - self.run_id = run_id - self.status = status - self.last_updated_time = last_updated_time - self.run_type = run_type - self.create_time = create_time - self.start_time = start_time - self.finish_time = finish_time - self.output_images = output_images - self.task = task - self.image_update_trigger = image_update_trigger - self.source_trigger = source_trigger - self.platform = platform - self.agent_configuration = agent_configuration - self.source_registry_auth = source_registry_auth - self.custom_registries = custom_registries - self.run_error_message = None - self.provisioning_state = provisioning_state - self.is_archive_enabled = is_archive_enabled - self.timer_trigger = timer_trigger - - -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. 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. 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 - :ivar finish_time: The time the run finished. - :vartype finish_time: ~datetime.datetime - :ivar output_image_manifests: The list of comma-separated image manifests that were generated - from the run. This is applicable if the run is of - build type. - :vartype output_image_manifests: str - :ivar is_archive_enabled: The value that indicates whether archiving is enabled or not. - :vartype is_archive_enabled: bool - :ivar task_name: The name of the task that the run corresponds to. - :vartype task_name: str - """ - - _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"}, - } - - def __init__( - self, - *, - run_id: Optional[str] = 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, - is_archive_enabled: Optional[bool] = None, - task_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword run_id: The unique identifier for the run. - :paramtype run_id: str - :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. 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 - :keyword finish_time: The time the run finished. - :paramtype finish_time: ~datetime.datetime - :keyword output_image_manifests: The list of comma-separated image manifests that were - generated from the run. This is applicable if the run is of - build type. - :paramtype output_image_manifests: str - :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. - :paramtype is_archive_enabled: bool - :keyword task_name: The name of the task that the run corresponds to. - :paramtype task_name: str - """ - super().__init__(**kwargs) - self.run_id = run_id - self.run_type = run_type - self.status = status - self.create_time = create_time - self.finish_time = finish_time - self.output_image_manifests = output_image_manifests - self.is_archive_enabled = is_archive_enabled - self.task_name = task_name - - -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. - :vartype log_link: str - """ - - _attribute_map = { - "log_link": {"key": "logLink", "type": "str"}, - } - - def __init__(self, *, log_link: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword log_link: The link to logs for a run on a azure container registry. - :paramtype log_link: str - """ - super().__init__(**kwargs) - self.log_link = log_link - - -class RunListResult(_serialization.Model): - """Collection of runs. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.containerregistry.v2019_04_01.models.Run] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Run]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Run"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -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. - :vartype is_archive_enabled: bool - """ - - _attribute_map = { - "is_archive_enabled": {"key": "isArchiveEnabled", "type": "bool"}, - } - - def __init__(self, *, is_archive_enabled: Optional[bool] = None, **kwargs: Any) -> None: - """ - :keyword is_archive_enabled: The value that indicates whether archiving is enabled or not. - :paramtype is_archive_enabled: bool - """ - super().__init__(**kwargs) - self.is_archive_enabled = is_archive_enabled - - -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 - based on the type of the secret object. If the type is Opaque, the value will be - used as is without any modification. - :vartype value: str - :ivar type: The type of the secret object which determines how the value of the secret object - has to be - 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"}, - } - - def __init__( - self, - *, - value: Optional[str] = None, - type: Optional[Union[str, "_models.SecretObjectType"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword value: The value of the secret. The format of this value will be determined - based on the type of the secret object. If the type is Opaque, the value will be - used as is without any modification. - :paramtype value: str - :keyword type: The type of the secret object which determines how the value of the secret - object has to be - interpreted. Known values are: "Opaque" and "Vaultsecret". - :paramtype type: str or ~azure.mgmt.containerregistry.v2019_04_01.models.SecretObjectType - """ - super().__init__(**kwargs) - self.value = value - self.type = type - - -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 server. - - :ivar name: The name of the overridable value. Required. - :vartype name: str - :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}, - } - - _attribute_map = { - "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: bool = False, **kwargs: Any) -> None: - """ - :keyword name: The name of the overridable value. Required. - :paramtype name: str - :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().__init__(**kwargs) - self.name = name - self.value = value - self.is_secret = is_secret - - -class SourceProperties(_serialization.Model): - """The properties of the source code repository. - - All required parameters must be populated in order to send to server. - - :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: 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 - :ivar source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :vartype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2019_04_01.models.AuthInfo - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - source_control_type: Union[str, "_models.SourceControlType"], - repository_url: str, - branch: Optional[str] = None, - source_control_auth_properties: Optional["_models.AuthInfo"] = None, - **kwargs: Any - ) -> None: - """ - :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: 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 - :keyword source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :paramtype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2019_04_01.models.AuthInfo - """ - 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(_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. 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"}, - } - - def __init__( - self, *, login_mode: Optional[Union[str, "_models.SourceRegistryLoginMode"]] = None, **kwargs: Any - ) -> None: - """ - :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. Known values are: "None" and "Default". - :paramtype login_mode: str or - ~azure.mgmt.containerregistry.v2019_04_01.models.SourceRegistryLoginMode - """ - super().__init__(**kwargs) - self.login_mode = login_mode - - -class SourceTrigger(_serialization.Model): - """The properties of a source based trigger. - - All required parameters must be populated in order to send to server. - - :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: 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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - source_repository: "_models.SourceProperties", - source_trigger_events: List[Union[str, "_models.SourceTriggerEvent"]], - name: str, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :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: 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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.source_repository = source_repository - self.source_trigger_events = source_trigger_events - self.status = status - self.name = name - - -class SourceTriggerDescriptor(_serialization.Model): - """The source trigger that caused a run. - - :ivar id: The unique ID of the trigger. - :vartype id: str - :ivar event_type: The event type of the trigger. - :vartype event_type: str - :ivar commit_id: The unique ID that identifies a commit. - :vartype commit_id: str - :ivar pull_request_id: The unique ID that identifies pull request. - :vartype pull_request_id: str - :ivar repository_url: The repository URL. - :vartype repository_url: str - :ivar branch_name: The branch name in the repository. - :vartype branch_name: str - :ivar provider_type: The source control provider type. - :vartype provider_type: str - """ - - _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"}, - } - - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - event_type: Optional[str] = None, - commit_id: Optional[str] = None, - pull_request_id: Optional[str] = None, - repository_url: Optional[str] = None, - branch_name: Optional[str] = None, - provider_type: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword id: The unique ID of the trigger. - :paramtype id: str - :keyword event_type: The event type of the trigger. - :paramtype event_type: str - :keyword commit_id: The unique ID that identifies a commit. - :paramtype commit_id: str - :keyword pull_request_id: The unique ID that identifies pull request. - :paramtype pull_request_id: str - :keyword repository_url: The repository URL. - :paramtype repository_url: str - :keyword branch_name: The branch name in the repository. - :paramtype branch_name: str - :keyword provider_type: The source control provider type. - :paramtype provider_type: str - """ - super().__init__(**kwargs) - self.id = id - self.event_type = event_type - self.commit_id = commit_id - self.pull_request_id = pull_request_id - self.repository_url = repository_url - self.branch_name = branch_name - self.provider_type = provider_type - - -class SourceTriggerUpdateParameters(_serialization.Model): - """The properties for updating a source based trigger. - - All required parameters must be populated in order to send to server. - - :ivar source_repository: The properties that describes the source(code) for the task. - :vartype source_repository: - ~azure.mgmt.containerregistry.v2019_04_01.models.SourceUpdateParameters - :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. Known values are: "Disabled" and "Enabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :ivar name: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "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"}, - } - - def __init__( - self, - *, - name: str, - source_repository: Optional["_models.SourceUpdateParameters"] = None, - source_trigger_events: Optional[List[Union[str, "_models.SourceTriggerEvent"]]] = None, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword source_repository: The properties that describes the source(code) for the task. - :paramtype source_repository: - ~azure.mgmt.containerregistry.v2019_04_01.models.SourceUpdateParameters - :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. Known values are: "Disabled" and "Enabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerStatus - :keyword name: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.source_repository = source_repository - self.source_trigger_events = source_trigger_events - self.status = status - self.name = name - - -class SourceUpdateParameters(_serialization.Model): - """The properties for updating the source code repository. - - :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. - :vartype repository_url: str - :ivar branch: The branch name of the source code. - :vartype branch: str - :ivar source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :vartype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2019_04_01.models.AuthInfoUpdateParameters - """ - - _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"}, - } - - def __init__( - self, - *, - source_control_type: Optional[Union[str, "_models.SourceControlType"]] = None, - repository_url: Optional[str] = None, - branch: Optional[str] = None, - source_control_auth_properties: Optional["_models.AuthInfoUpdateParameters"] = None, - **kwargs: Any - ) -> None: - """ - :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. - :paramtype repository_url: str - :keyword branch: The branch name of the source code. - :paramtype branch: str - :keyword source_control_auth_properties: The authorization properties for accessing the source - code repository and to set up - webhooks for notifications. - :paramtype source_control_auth_properties: - ~azure.mgmt.containerregistry.v2019_04_01.models.AuthInfoUpdateParameters - """ - 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(_serialization.Model): - """The properties of a response to source upload request. - - :ivar upload_url: The URL where the client can upload the source. - :vartype upload_url: str - :ivar relative_path: The relative path to the source. This is used to submit the subsequent - queue build request. - :vartype relative_path: str - """ - - _attribute_map = { - "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: Any) -> None: - """ - :keyword upload_url: The URL where the client can upload the source. - :paramtype upload_url: str - :keyword relative_path: The relative path to the source. This is used to submit the subsequent - queue build request. - :paramtype relative_path: str - """ - 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 server. - - :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}, - } - - _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"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = 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: Any - ) -> None: - """ - :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 identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.containerregistry.v2019_04_01.models.IdentityProperties - :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 - :keyword agent_configuration: The machine configuration of the run agent. - :paramtype agent_configuration: - ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :keyword step: The properties of a task step. - :paramtype step: ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStepProperties - :keyword trigger: The properties that describe all triggers for the task. - :paramtype trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerProperties - :keyword credentials: The properties that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials - """ - super().__init__(location=location, tags=tags, **kwargs) - self.identity = identity - self.provisioning_state = None - self.creation_date = None - self.status = status - self.platform = platform - self.agent_configuration = agent_configuration - self.timeout = timeout - self.step = step - self.trigger = trigger - self.credentials = credentials - - -class TaskListResult(_serialization.Model): - """The collection of tasks. - - :ivar value: The collection value. - :vartype value: list[~azure.mgmt.containerregistry.v2019_04_01.models.Task] - :ivar next_link: The URI that can be used to request the next set of paged results. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Task]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Task"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class TaskRunRequest(RunRequest): - """The parameters for a task run request. - - All required parameters must be populated in order to send to 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: 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}, - } - - _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]"}, - } - - def __init__( - self, - *, - task_name: str, - is_archive_enabled: bool = False, - values: Optional[List["_models.SetValue"]] = None, - **kwargs: Any - ) -> None: - """ - :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: 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().__init__(is_archive_enabled=is_archive_enabled, **kwargs) - self.type: str = "TaskRunRequest" - self.task_name = task_name - self.values = values - - -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: The ARM resource tags. - :vartype tags: dict[str, str] - :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 - :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 for updating a task step. - :vartype step: ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStepUpdateParameters - :ivar trigger: The properties for updating trigger properties. - :vartype trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerUpdateParameters - :ivar credentials: The parameters 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 - """ - - _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"}, - } - - def __init__( - self, - *, - identity: Optional["_models.IdentityProperties"] = None, - tags: Optional[Dict[str, str]] = 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["_models.TaskStepUpdateParameters"] = None, - trigger: Optional["_models.TriggerUpdateParameters"] = None, - credentials: Optional["_models.Credentials"] = None, - **kwargs: Any - ) -> None: - """ - :keyword identity: Identity for the resource. - :paramtype identity: ~azure.mgmt.containerregistry.v2019_04_01.models.IdentityProperties - :keyword tags: The ARM resource tags. - :paramtype tags: dict[str, str] - :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 - :keyword agent_configuration: The machine configuration of the run agent. - :paramtype agent_configuration: - ~azure.mgmt.containerregistry.v2019_04_01.models.AgentProperties - :keyword timeout: Run timeout in seconds. - :paramtype timeout: int - :keyword step: The properties for updating a task step. - :paramtype step: ~azure.mgmt.containerregistry.v2019_04_01.models.TaskStepUpdateParameters - :keyword trigger: The properties for updating trigger properties. - :paramtype trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.TriggerUpdateParameters - :keyword credentials: The parameters that describes a set of credentials that will be used when - this run is invoked. - :paramtype credentials: ~azure.mgmt.containerregistry.v2019_04_01.models.Credentials - """ - super().__init__(**kwargs) - self.identity = identity - self.tags = tags - self.status = status - self.platform = platform - self.agent_configuration = agent_configuration - self.timeout = timeout - self.step = step - self.trigger = trigger - self.credentials = credentials - - -class TimerTrigger(_serialization.Model): - """The properties of a timer trigger. - - All required parameters must be populated in order to send to server. - - :ivar schedule: The CRON expression for the task schedule. Required. - :vartype schedule: str - :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: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "schedule": {"required": True}, - "name": {"required": True}, - } - - _attribute_map = { - "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, "_models.TriggerStatus"]] = None, **kwargs: Any - ) -> None: - """ - :keyword schedule: The CRON expression for the task schedule. Required. - :paramtype schedule: str - :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: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.schedule = schedule - self.status = status - self.name = name - - -class TimerTriggerDescriptor(_serialization.Model): - """TimerTriggerDescriptor. - - :ivar timer_trigger_name: The timer trigger name that caused the run. - :vartype timer_trigger_name: str - :ivar schedule_occurrence: The occurrence that triggered the run. - :vartype schedule_occurrence: str - """ - - _attribute_map = { - "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: Any - ) -> None: - """ - :keyword timer_trigger_name: The timer trigger name that caused the run. - :paramtype timer_trigger_name: str - :keyword schedule_occurrence: The occurrence that triggered the run. - :paramtype schedule_occurrence: str - """ - super().__init__(**kwargs) - self.timer_trigger_name = timer_trigger_name - self.schedule_occurrence = schedule_occurrence - - -class TimerTriggerUpdateParameters(_serialization.Model): - """The properties for updating a timer trigger. - - All required parameters must be populated in order to send to server. - - :ivar schedule: The CRON expression for the task schedule. - :vartype schedule: str - :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: The name of the trigger. Required. - :vartype name: str - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "schedule": {"key": "schedule", "type": "str"}, - "status": {"key": "status", "type": "str"}, - "name": {"key": "name", "type": "str"}, - } - - def __init__( - self, - *, - name: str, - schedule: Optional[str] = None, - status: Optional[Union[str, "_models.TriggerStatus"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword schedule: The CRON expression for the task schedule. - :paramtype schedule: str - :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: The name of the trigger. Required. - :paramtype name: str - """ - super().__init__(**kwargs) - self.schedule = schedule - self.status = status - self.name = name - - -class TriggerProperties(_serialization.Model): - """The properties of a trigger. - - :ivar timer_triggers: The collection of timer triggers. - :vartype timer_triggers: list[~azure.mgmt.containerregistry.v2019_04_01.models.TimerTrigger] - :ivar source_triggers: The collection of triggers based on source code repository. - :vartype source_triggers: list[~azure.mgmt.containerregistry.v2019_04_01.models.SourceTrigger] - :ivar base_image_trigger: The trigger based on base image dependencies. - :vartype base_image_trigger: ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTrigger - """ - - _attribute_map = { - "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["_models.TimerTrigger"]] = None, - source_triggers: Optional[List["_models.SourceTrigger"]] = None, - base_image_trigger: Optional["_models.BaseImageTrigger"] = None, - **kwargs: Any - ) -> None: - """ - :keyword timer_triggers: The collection of timer triggers. - :paramtype timer_triggers: list[~azure.mgmt.containerregistry.v2019_04_01.models.TimerTrigger] - :keyword source_triggers: The collection of triggers based on source code repository. - :paramtype source_triggers: - list[~azure.mgmt.containerregistry.v2019_04_01.models.SourceTrigger] - :keyword base_image_trigger: The trigger based on base image dependencies. - :paramtype base_image_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTrigger - """ - super().__init__(**kwargs) - self.timer_triggers = timer_triggers - self.source_triggers = source_triggers - self.base_image_trigger = base_image_trigger - - -class TriggerUpdateParameters(_serialization.Model): - """The properties for updating triggers. - - :ivar timer_triggers: The collection of timer triggers. - :vartype timer_triggers: - list[~azure.mgmt.containerregistry.v2019_04_01.models.TimerTriggerUpdateParameters] - :ivar source_triggers: The collection of triggers based on source code repository. - :vartype source_triggers: - list[~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerUpdateParameters] - :ivar base_image_trigger: The trigger based on base image dependencies. - :vartype base_image_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTriggerUpdateParameters - """ - - _attribute_map = { - "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["_models.TimerTriggerUpdateParameters"]] = None, - source_triggers: Optional[List["_models.SourceTriggerUpdateParameters"]] = None, - base_image_trigger: Optional["_models.BaseImageTriggerUpdateParameters"] = None, - **kwargs: Any - ) -> None: - """ - :keyword timer_triggers: The collection of timer triggers. - :paramtype timer_triggers: - list[~azure.mgmt.containerregistry.v2019_04_01.models.TimerTriggerUpdateParameters] - :keyword source_triggers: The collection of triggers based on source code repository. - :paramtype source_triggers: - list[~azure.mgmt.containerregistry.v2019_04_01.models.SourceTriggerUpdateParameters] - :keyword base_image_trigger: The trigger based on base image dependencies. - :paramtype base_image_trigger: - ~azure.mgmt.containerregistry.v2019_04_01.models.BaseImageTriggerUpdateParameters - """ - super().__init__(**kwargs) - self.timer_triggers = timer_triggers - self.source_triggers = source_triggers - self.base_image_trigger = base_image_trigger - - -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: Any) -> None: - """ - :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 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index d57838606437..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._runs_operations import RunsOperations # type: ignore -from ._tasks_operations import TasksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "RunsOperations", - "TasksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 74966065805b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_registries_operations.py +++ /dev/null @@ -1,375 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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") - - # Construct URL - _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]*$" - ), - } - - _url: str = _url.format(**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_get_build_source_upload_url_request( # pylint: disable=name-too-long - 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: str = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _schedule_run_initial( - self, - resource_group_name: str, - registry_name: str, - run_request: Union[_models.RunRequest, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_request, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: _models.RunRequest, - *, - 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: ~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 - :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_schedule_run( - self, - resource_group_name: str, - registry_name: str, - run_request: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RunRequest - type or a IO[bytes] type. Required. - :type run_request: ~azure.mgmt.containerregistry.v2019_04_01.models.RunRequest or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_request=run_request, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Run](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_build_source_upload_url( - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: SourceUploadDefinition or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.SourceUploadDefinition - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.SourceUploadDefinition] = kwargs.pop("cls", None) - - _request = build_get_build_source_upload_url_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index ba572e94d0eb..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_runs_operations.py +++ /dev/null @@ -1,763 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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, - top: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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") - if top is not None: - _params["$top"] = _SERIALIZER.query("top", top, "int") - - # 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, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_update_request( - resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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") - - # Construct URL - _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"), - } - - _url: str = _url.format(**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_get_log_sas_url_request( - resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_cancel_request( - resource_group_name: str, registry_name: str, run_id: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, - resource_group_name: str, - registry_name: str, - filter: Optional[str] = None, - top: Optional[int] = None, - **kwargs: Any - ) -> 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. Required. - :type resource_group_name: str - :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', - 'Has', 'All' are allowed. Default value is None. - :type filter: str - :param top: $top is supported for get list of runs, which limits the maximum number of runs to - return. Default value is None. - :type top: int - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.RunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - top=top, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - 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. 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 - :return: Run or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Run - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.Run] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(run_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - run_id: str, - run_update_parameters: Union[_models.RunUpdateParameters, IO[bytes]], - **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. Is either a RunUpdateParameters type - or a IO[bytes] type. Required. - :type run_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.RunUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - run_id=run_id, - run_update_parameters=run_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Run", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Run].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Run](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def get_log_sas_url( - 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. 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 - :return: RunGetLogResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.RunGetLogResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.RunGetLogResult] = kwargs.pop("cls", None) - - _request = build_get_log_sas_url_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _cancel_initial( - self, resource_group_name: str, registry_name: str, run_id: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - run_id=run_id, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index eeef2d127a45..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/operations/_tasks_operations.py +++ /dev/null @@ -1,988 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, task_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: str = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, task_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: str = 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") - - # Construct URL - _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-_]*$" - ), - } - - _url: str = _url.format(**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, task_name: str, subscription_id: str, **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, task_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: str = 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") - - # Construct URL - _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-_]*$" - ), - } - - _url: str = _url.format(**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_get_details_request( - resource_group_name: str, registry_name: str, task_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: str = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) - accept = _headers.pop("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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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 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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - 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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.TaskListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - 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) # type: ignore - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_create_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_create_parameters: Union[_models.Task, IO[bytes]], - **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. Is either a Task type or a - IO[bytes] type. Required. - :type task_create_parameters: ~azure.mgmt.containerregistry.v2019_04_01.models.Task or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_create_parameters=task_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, task_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - 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. 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - resource_group_name=resource_group_name, - registry_name=registry_name, - task_name=task_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(task_update_parameters, (IOBase, 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, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - task_name: str, - task_update_parameters: Union[_models.TaskUpdateParameters, IO[bytes]], - **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. Is either a - TaskUpdateParameters type or a IO[bytes] type. Required. - :type task_update_parameters: - ~azure.mgmt.containerregistry.v2019_04_01.models.TaskUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - registry_name=registry_name, - task_name=task_name, - task_update_parameters=task_update_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Task", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Task].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Task]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - 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. 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 - :return: Task or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_04_01.models.Task - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2019-04-01")) - cls: ClsType[_models.Task] = kwargs.pop("cls", None) - - _request = build_get_details_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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_04_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 ae876c37f272..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 = "11.0.0" +VERSION = "1.0.0b1" 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 ae876c37f272..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 = "11.0.0" +VERSION = "1.0.0b1" 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 ae876c37f272..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 = "11.0.0" +VERSION = "1.0.0b1" 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index e5baf726b272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2019-12-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index da1f80b9e7c9..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_container_registry_management_client.py +++ /dev/null @@ -1,164 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -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, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2019_12_01_preview.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2019_12_01_preview.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2019_12_01_preview.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2019_12_01_preview.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2019_12_01_preview.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2019_12_01_preview.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2019_12_01_preview.operations.ReplicationsOperations - :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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index 743280c73392..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_metadata.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "chosen_version": "2019-12-01-preview", - "total_api_version_list": ["2019-12-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "export_pipelines": "ExportPipelinesOperations", - "registries": "RegistriesOperations", - "import_pipelines": "ImportPipelinesOperations", - "operations": "Operations", - "pipeline_runs": "PipelineRunsOperations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "replications": "ReplicationsOperations", - "webhooks": "WebhooksOperations" - } -} 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index c133627eb67b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2019-12-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index 04956e7e3c1e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_container_registry_management_client.py +++ /dev/null @@ -1,166 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -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, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2019_12_01_preview.aio.operations.ReplicationsOperations - :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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2019-12-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index e8f69ed5abba..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ExportPipelinesOperations", - "RegistriesOperations", - "ImportPipelinesOperations", - "Operations", - "PipelineRunsOperations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index b1c3bc96676c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,544 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._export_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExportPipeline"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index c4caaad6b7fe..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,544 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._import_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImportPipeline"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index a8a7ea6738f5..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - # pylint: disable=line-too-long - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 808b5a4405b8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,539 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._pipeline_runs_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **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. Is either a - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index a153b0d47928..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,551 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 04295c4e8b82..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1436 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_async - async def check_name_availability( - self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_private_link_resources( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResource"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index b207fd9e8065..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_replications_operations.py +++ /dev/null @@ -1,753 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_create( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 298045bd2645..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,969 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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.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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index bb28e4f980b3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/__init__.py +++ /dev/null @@ -1,230 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - 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 ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index e92f11bf1a3a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,203 +0,0 @@ -# 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 virtual network 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 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 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): - """The provisioning state of the pipeline at the time the operation was called.""" - - 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 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" 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 deleted file mode 100644 index eaf16c1c0e0a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_models_py3.py +++ /dev/null @@ -1,3604 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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.v2019_12_01_preview.models.EncryptionStatus - :ivar key_vault_properties: Key vault properties. - :vartype key_vault_properties: - ~azure.mgmt.containerregistry.v2019_12_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: Any - ) -> None: - """ - :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.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().__init__(**kwargs) - self.status = status - self.key_vault_properties = key_vault_properties - - -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: Any) -> None: # 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.v2019_12_01_preview.models.EventRequestMessage - :ivar event_response_message: The event response message received from the service URI. - :vartype event_response_message: - ~azure.mgmt.containerregistry.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_01_preview.models.EventRequestMessage - :keyword event_response_message: The event response message received from the service URI. - :paramtype event_response_message: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_01_preview.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_01_preview.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2019_12_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: Any - ) -> None: - """ - :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 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.v2019_12_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -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.v2019_12_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.v2019_12_01_preview.models.IdentityProperties - :ivar target: The target properties of the export pipeline. - :vartype target: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipelineTargetProperties - :ivar options: The list of all options configured for the pipeline. - :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. 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}, - } - - _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: Any - ) -> None: - """ - :keyword location: The location of the export pipeline. - :paramtype location: str - :keyword identity: The identity of the export pipeline. - :paramtype identity: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.IdentityProperties - :keyword target: The target properties of the export pipeline. - :paramtype target: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipelineTargetProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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 server. - - :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: Any - ) -> None: - """ - :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 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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_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 server. - - :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). - :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.v2019_12_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: Any - ) -> None: - """ - :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). - :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.v2019_12_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.v2019_12_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.v2019_12_01_preview.models.IdentityProperties - :ivar source: The source properties of the import pipeline. - :vartype source: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipelineSourceProperties - :ivar trigger: The properties that describe the trigger of the import pipeline. - :vartype trigger: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineTriggerProperties - :ivar options: The list of all options configured for the pipeline. - :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. 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}, - } - - _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: Any - ) -> None: - """ - :keyword location: The location of the import pipeline. - :paramtype location: str - :keyword identity: The identity of the import pipeline. - :paramtype identity: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.IdentityProperties - :keyword source: The source properties of the import pipeline. - :paramtype source: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipelineSourceProperties - :keyword trigger: The properties that describe the trigger of the import pipeline. - :paramtype trigger: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineTriggerProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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 server. - - :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: 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: Any - ) -> None: - """ - :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: 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 server. - - :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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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 server. - - :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: Any) -> None: - """ - :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 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 server. - - :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: 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: Optional[Union[str, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: 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: Any) -> None: - """ - :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 server. - - :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. - :vartype virtual_network_rules: - list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.VirtualNetworkRule] - :ivar ip_rules: The IP ACL rules. - :vartype ip_rules: list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.IPRule] - """ - - _validation = { - "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]"}, - } - - def __init__( - self, - *, - default_action: Union[str, "_models.DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, - ip_rules: Optional[List["_models.IPRule"]] = None, - **kwargs: Any - ) -> None: - """ - :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. - :paramtype virtual_network_rules: - list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.VirtualNetworkRule] - :keyword ip_rules: The IP ACL rules. - :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.IPRule] - """ - super().__init__(**kwargs) - self.default_action = default_action - self.virtual_network_rules = virtual_network_rules - 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.v2019_12_01_preview.models.OperationDisplayDefinition - :ivar service_specification: The definition of Azure Monitoring service. - :vartype service_specification: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationServiceSpecificationDefinition - """ - - _attribute_map = { - "origin": {"key": "origin", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplayDefinition"}, - "service_specification": { - "key": "properties.serviceSpecification", - "type": "OperationServiceSpecificationDefinition", - }, - } - - def __init__( - self, - *, - origin: Optional[str] = None, - name: Optional[str] = None, - display: Optional["_models.OperationDisplayDefinition"] = None, - service_specification: Optional["_models.OperationServiceSpecificationDefinition"] = None, - **kwargs: Any - ) -> None: - """ - :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.v2019_12_01_preview.models.OperationDisplayDefinition - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationServiceSpecificationDefinition - """ - super().__init__(**kwargs) - self.origin = origin - self.name = name - self.display = display - 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: Any - ) -> None: - """ - :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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2019_12_01_preview.models.OperationMetricSpecificationDefinition] - :ivar log_specifications: A list of Azure Monitoring log definitions. - :vartype log_specifications: - list[~azure.mgmt.containerregistry.v2019_12_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: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationMetricSpecificationDefinition] - :keyword log_specifications: A list of Azure Monitoring log definitions. - :paramtype log_specifications: - list[~azure.mgmt.containerregistry.v2019_12_01_preview.models.OperationLogSpecificationDefinition] - """ - super().__init__(**kwargs) - self.metric_specifications = metric_specifications - self.log_specifications = log_specifications - - -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.v2019_12_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.v2019_12_01_preview.models.ProvisioningState - :ivar request: The request parameters for a pipeline run. - :vartype request: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRunRequest - :ivar response: The response of a pipeline run. - :vartype response: ~azure.mgmt.containerregistry.v2019_12_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: Any - ) -> None: - """ - :keyword request: The request parameters for a pipeline run. - :paramtype request: ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_01_preview.models.PipelineRunSourceProperties - :ivar target: The target properties of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_01_preview.models.PipelineRunSourceProperties - :keyword target: The target properties of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_01_preview.models.ImportPipelineSourceProperties - :ivar target: The target of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_01_preview.models.ImportPipelineSourceProperties - :keyword target: The target of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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().__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.v2019_12_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: Any - ) -> None: - """ - :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().__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: Any) -> None: - """ - :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 server. - - :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}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs: Any) -> None: - """ - :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().__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.v2019_12_01_preview.models.PipelineSourceTriggerDescriptor - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger that caused the pipeline run. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_01_preview.models.PipelineSourceTriggerProperties - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger properties of the pipeline. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_01_preview.models.QuarantinePolicy - :ivar trust_policy: The content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.TrustPolicy - :ivar retention_policy: The retention policy for a container registry. - :vartype retention_policy: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RetentionPolicy - """ - - _attribute_map = { - "quarantine_policy": {"key": "quarantinePolicy", "type": "QuarantinePolicy"}, - "trust_policy": {"key": "trustPolicy", "type": "TrustPolicy"}, - "retention_policy": {"key": "retentionPolicy", "type": "RetentionPolicy"}, - } - - def __init__( - self, - *, - quarantine_policy: Optional["_models.QuarantinePolicy"] = None, - trust_policy: Optional["_models.TrustPolicy"] = None, - retention_policy: Optional["_models.RetentionPolicy"] = None, - **kwargs: Any - ) -> None: - """ - :keyword quarantine_policy: The quarantine policy for a container registry. - :paramtype quarantine_policy: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.QuarantinePolicy - :keyword trust_policy: The content trust policy for a container registry. - :paramtype trust_policy: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.TrustPolicy - :keyword retention_policy: The retention policy for a container registry. - :paramtype retention_policy: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RetentionPolicy - """ - super().__init__(**kwargs) - self.quarantine_policy = quarantine_policy - self.trust_policy = trust_policy - self.retention_policy = retention_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: Any) -> None: # 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.v2019_12_01_preview.models.SystemData - :ivar private_endpoint: The resource of private endpoint. - :vartype private_endpoint: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private endpoint. - :paramtype private_endpoint: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.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. 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"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.ConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, - **kwargs: Any - ) -> None: - """ - :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. Known values are: "None" and "Recreate". - :paramtype actions_required: str or - ~azure.mgmt.containerregistry.v2019_12_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: Any) -> None: - """ - :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.v2019_12_01_preview.models.PolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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().__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 server. - - :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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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().__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 server. - - :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_12_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: Any) -> None: - """ - :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): - """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 server. - - :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_12_01_preview.models.SystemData - :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 - :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.v2019_12_01_preview.models.ProvisioningState - :ivar status: The status of the container registry at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_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.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"}, - } - - 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, - **kwargs: Any - ) -> None: - """ - :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.v2019_12_01_preview.models.Sku - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_01_preview.models.NetworkRuleBypassOptions - """ - 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 - - -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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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.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"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__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.v2019_12_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.v2019_12_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.v2019_12_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.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"}, - } - - 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: Any - ) -> None: - """ - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2019_12_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.v2019_12_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.v2019_12_01_preview.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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_01_preview.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2019_12_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 server. - - :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_12_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.v2019_12_01_preview.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2019_12_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 - """ - - _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"}, - } - - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - region_endpoint_enabled: bool = True, - **kwargs: Any - ) -> None: - """ - :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 - """ - super().__init__(location=location, tags=tags, **kwargs) - self.provisioning_state = None - self.status = None - self.region_endpoint_enabled = region_endpoint_enabled - - -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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_01_preview.models.PolicyStatus - """ - super().__init__(**kwargs) - self.days = days - self.last_updated_time = None - self.status = status - - -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 server. - - :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. 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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: - """ - :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().__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: Any) -> None: - """ - :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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.display_status = None - self.message = None - self.timestamp = None - - -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.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. 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). - :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: Any - ) -> None: - """ - :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.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. 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().__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: Any - ) -> None: - """ - :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 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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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. Known values - are: "enabled" and "disabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2019_12_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: Any) -> None: - """ - :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 VirtualNetworkRule(_serialization.Model): - """Virtual network rule. - - All required parameters must be populated in order to send to server. - - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :vartype virtual_network_resource_id: str - """ - - _validation = { - "virtual_network_resource_id": {"required": True}, - } - - _attribute_map = { - "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, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :paramtype virtual_network_resource_id: str - """ - super().__init__(**kwargs) - self.action = action - self.virtual_network_resource_id = virtual_network_resource_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 server. - - :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_12_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.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. - '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.v2019_12_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.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}, - } - - _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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_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 server. - - :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.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. - '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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.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. - '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.v2019_12_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: Any - ) -> None: - """ - :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.v2019_12_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.v2019_12_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/v2019_12_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index e8f69ed5abba..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/__init__.py +++ /dev/null @@ -1,39 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ExportPipelinesOperations", - "RegistriesOperations", - "ImportPipelinesOperations", - "Operations", - "PipelineRunsOperations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 18367b1ce760..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ExportPipeline or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 054d492f6dfe..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportPipeline or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index b4d1c13025d7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - _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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 598853d59136..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,674 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **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. Is either a - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PipelineRun or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 0cb94f81eb68..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,698 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 1246e6d9a79c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_registries_operations.py +++ /dev/null @@ -1,1797 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), - } - - _url: str = _url.format(**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_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: str = 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" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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( # pylint: disable=name-too-long - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Registry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 61a7e08211f0..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_replications_operations.py +++ /dev/null @@ -1,926 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -class ReplicationsOperations: - """ - .. 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:`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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Replication or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 492a9debcb89..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/operations/_webhooks_operations.py +++ /dev/null @@ -1,1238 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2019_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2019_12_01_preview.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2019_12_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2019-12-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2019_12_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 ae876c37f272..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 = "11.0.0" +VERSION = "1.0.0b1" 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 5d5dbd3e0bfb..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2021-06-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index 8aa923abf2cf..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_container_registry_management_client.py +++ /dev/null @@ -1,184 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -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, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.ConnectedRegistriesOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2021_06_01_preview.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2021_06_01_preview.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: azure.mgmt.containerregistry.v2021_06_01_preview.operations.TokensOperations - :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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index 848253db1235..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_metadata.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "chosen_version": "2021-06-01-preview", - "total_api_version_list": ["2021-06-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "connected_registries": "ConnectedRegistriesOperations", - "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/v2021_06_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_patch.py deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 19fbddf00509..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2021-06-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index e94680974a9b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_container_registry_management_client.py +++ /dev/null @@ -1,187 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -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, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.ConnectedRegistriesOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: - azure.mgmt.containerregistry.v2021_06_01_preview.aio.operations.TokensOperations - :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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-06-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index 3aa40339ecc3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ConnectedRegistriesOperations", - "ExportPipelinesOperations", - "RegistriesOperations", - "ImportPipelinesOperations", - "Operations", - "PipelineRunsOperations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "ScopeMapsOperations", - "TokensOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 6ad020752d38..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_connected_registries_operations.py +++ /dev/null @@ -1,887 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **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. - Is either a ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **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. - Is either a ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistry"]: - # pylint: disable=line-too-long - """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. 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 - :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.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - async def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 94d941a64816..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,544 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._export_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExportPipeline"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 3dceddd80d40..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,544 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._import_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: - """ - - @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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImportPipeline"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f4896253d6ea..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - # pylint: disable=line-too-long - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index db0e8455a009..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,539 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._pipeline_runs_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **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. Is either a - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index a6aa26eab002..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,551 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 3287519deb4b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1642 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_name_check_request, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_create( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_private_link_resources( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResource"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - async def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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. Is either a - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 1990386a0ef6..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_replications_operations.py +++ /dev/null @@ -1,753 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_create( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 6aac00f0e26c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_scope_maps_operations.py +++ /dev/null @@ -1,753 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_create( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **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. Is either a - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **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. Is either a - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 6dc820400ab3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_tokens_operations.py +++ /dev/null @@ -1,744 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._tokens_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **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. Is either a Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token - or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **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. Is either a - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 673e11782337..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,969 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 01c03f937efd..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/__init__.py +++ /dev/null @@ -1,310 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - 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 ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index e4b14b90779c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,291 +0,0 @@ -# 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 virtual network 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 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.""" - - 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 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/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 deleted file mode 100644 index 362ce6f08d57..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_models_py3.py +++ /dev/null @@ -1,4885 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - 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.v2021_06_01_preview.models.ActivationStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - 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: Any) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 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.v2021_06_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class ConnectedRegistry(ProxyResource): - """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.v2021_06_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.v2021_06_01_preview.models.ProvisioningState - :ivar mode: The mode of the connected registry resource that indicates the permissions of the - 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. 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. - :vartype last_activity_time: ~datetime.datetime - :ivar activation: The activation properties of the connected registry. - :vartype activation: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ActivationProperties - :ivar parent: The parent of the connected registry. - :vartype parent: ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_01_preview.models.LoginServerProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.LoggingProperties - :ivar status_details: The list of current statuses of the connected registry. - :vartype status_details: - list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.StatusDetailProperties] - """ - - _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]"}, - } - - 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, - **kwargs: Any - ) -> None: - """ - :keyword mode: The mode of the connected registry resource that indicates the permissions of - 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. - :paramtype parent: ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_01_preview.models.LoginServerProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.LoggingProperties - """ - 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 - - -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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_01_preview.models.SyncUpdateProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2021_06_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] - """ - - _attribute_map = { - "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["_models.SyncUpdateProperties"] = None, - logging: Optional["_models.LoggingProperties"] = None, - client_token_ids: Optional[List[str]] = None, - **kwargs: Any - ) -> None: - """ - :keyword sync_properties: The sync properties of the connected registry with its parent. - :paramtype sync_properties: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.SyncUpdateProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2021_06_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] - """ - super().__init__(**kwargs) - self.sync_properties = sync_properties - self.logging = logging - self.client_token_ids = client_token_ids - - -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.v2021_06_01_preview.models.EncryptionStatus - :ivar key_vault_properties: Key vault properties. - :vartype key_vault_properties: - ~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :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.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().__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.v2021_06_01_preview.models.ErrorResponseBody - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponseBody"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs: Any) -> None: - """ - :keyword error: Azure container registry build API error body. - :paramtype error: ~azure.mgmt.containerregistry.v2021_06_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 server. - - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any) -> None: # 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.v2021_06_01_preview.models.EventRequestMessage - :ivar event_response_message: The event response message received from the service URI. - :vartype event_response_message: - ~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_01_preview.models.EventRequestMessage - :keyword event_response_message: The event response message received from the service URI. - :paramtype event_response_message: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_01_preview.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_01_preview.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_01_preview.models.IdentityProperties - :ivar target: The target properties of the export pipeline. - :vartype target: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipelineTargetProperties - :ivar options: The list of all options configured for the pipeline. - :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. 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}, - } - - _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: Any - ) -> None: - """ - :keyword location: The location of the export pipeline. - :paramtype location: str - :keyword identity: The identity of the export pipeline. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.IdentityProperties - :keyword target: The target properties of the export pipeline. - :paramtype target: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipelineTargetProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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 server. - - :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: Any - ) -> None: - """ - :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.v2021_06_01_preview.models.ExportPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs: Any) -> None: - """ - :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().__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.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"}, - } - - def __init__( - self, - *, - token_id: Optional[str] = None, - expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "_models.TokenPasswordName"]] = None, - **kwargs: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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 server. - - :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). - :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.v2021_06_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: Any - ) -> None: - """ - :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). - :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.v2021_06_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.v2021_06_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.v2021_06_01_preview.models.IdentityProperties - :ivar source: The source properties of the import pipeline. - :vartype source: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipelineSourceProperties - :ivar trigger: The properties that describe the trigger of the import pipeline. - :vartype trigger: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineTriggerProperties - :ivar options: The list of all options configured for the pipeline. - :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. 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}, - } - - _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: Any - ) -> None: - """ - :keyword location: The location of the import pipeline. - :paramtype location: str - :keyword identity: The identity of the import pipeline. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.IdentityProperties - :keyword source: The source properties of the import pipeline. - :paramtype source: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipelineSourceProperties - :keyword trigger: The properties that describe the trigger of the import pipeline. - :paramtype trigger: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineTriggerProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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 server. - - :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: 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: Any - ) -> None: - """ - :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: 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 server. - - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: 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: Optional[Union[str, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: 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: Any) -> None: - """ - :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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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. - Known values are: "Enabled" and "Disabled". - :paramtype audit_log_status: str or - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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: Any) -> None: - """ """ - 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 server. - - :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. - :vartype virtual_network_rules: - list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.VirtualNetworkRule] - :ivar ip_rules: The IP ACL rules. - :vartype ip_rules: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.IPRule] - """ - - _validation = { - "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]"}, - } - - def __init__( - self, - *, - default_action: Union[str, "_models.DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, - ip_rules: Optional[List["_models.IPRule"]] = None, - **kwargs: Any - ) -> None: - """ - :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. - :paramtype virtual_network_rules: - list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.VirtualNetworkRule] - :keyword ip_rules: The IP ACL rules. - :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.IPRule] - """ - super().__init__(**kwargs) - self.default_action = default_action - self.virtual_network_rules = virtual_network_rules - 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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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. # pylint: disable=line-too-long - :paramtype is_data_action: bool - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2021_06_01_preview.models.OperationMetricSpecificationDefinition] - :ivar log_specifications: A list of Azure Monitoring log definitions. - :vartype log_specifications: - list[~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationMetricSpecificationDefinition] - :keyword log_specifications: A list of Azure Monitoring log definitions. - :paramtype log_specifications: - list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.OperationLogSpecificationDefinition] - """ - super().__init__(**kwargs) - self.metric_specifications = metric_specifications - self.log_specifications = log_specifications - - -class ParentProperties(_serialization.Model): - """The properties of the connected registry parent. - - All required parameters must be populated in order to send to server. - - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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.v2021_06_01_preview.models.ProvisioningState - :ivar request: The request parameters for a pipeline run. - :vartype request: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRunRequest - :ivar response: The response of a pipeline run. - :vartype response: ~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :keyword request: The request parameters for a pipeline run. - :paramtype request: ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_01_preview.models.PipelineRunSourceProperties - :ivar target: The target properties of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_01_preview.models.PipelineRunSourceProperties - :keyword target: The target properties of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_01_preview.models.ImportPipelineSourceProperties - :ivar target: The target of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_01_preview.models.ImportPipelineSourceProperties - :keyword target: The target of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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().__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.v2021_06_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: Any - ) -> None: - """ - :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().__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: Any) -> None: - """ - :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 server. - - :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}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs: Any) -> None: - """ - :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().__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.v2021_06_01_preview.models.PipelineSourceTriggerDescriptor - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger that caused the pipeline run. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_01_preview.models.PipelineSourceTriggerProperties - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger properties of the pipeline. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_01_preview.models.QuarantinePolicy - :ivar trust_policy: The content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TrustPolicy - :ivar retention_policy: The retention policy for a container registry. - :vartype retention_policy: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RetentionPolicy - :ivar export_policy: The export policy for a container registry. - :vartype export_policy: ~azure.mgmt.containerregistry.v2021_06_01_preview.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: Any - ) -> None: - """ - :keyword quarantine_policy: The quarantine policy for a container registry. - :paramtype quarantine_policy: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.QuarantinePolicy - :keyword trust_policy: The content trust policy for a container registry. - :paramtype trust_policy: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TrustPolicy - :keyword retention_policy: The retention policy for a container registry. - :paramtype retention_policy: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RetentionPolicy - :keyword export_policy: The export policy for a container registry. - :paramtype export_policy: ~azure.mgmt.containerregistry.v2021_06_01_preview.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: Any) -> None: # 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.v2021_06_01_preview.models.SystemData - :ivar private_endpoint: The resource of private endpoint. - :vartype private_endpoint: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private endpoint. - :paramtype private_endpoint: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.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. 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"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.ConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, - **kwargs: Any - ) -> None: - """ - :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. Known values are: "None" and "Recreate". - :paramtype actions_required: str or - ~azure.mgmt.containerregistry.v2021_06_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: Any) -> None: - """ - :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.v2021_06_01_preview.models.PolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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().__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 server. - - :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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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().__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 server. - - :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.v2021_06_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: Any) -> None: - """ - :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): - """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 server. - - :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.v2021_06_01_preview.models.SystemData - :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 - :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.v2021_06_01_preview.models.ProvisioningState - :ivar status: The status of the container registry at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_01_preview.models.Sku - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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.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"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__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.v2021_06_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.v2021_06_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.v2021_06_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_01_preview.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2021_06_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 server. - - :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.v2021_06_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.v2021_06_01_preview.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2021_06_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.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}, - } - - _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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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: Any - ) -> None: - """ - :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 server. - - :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. 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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: - """ - :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().__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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.code = None - self.description = None - self.timestamp = None - self.correlation_id = None - - -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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.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. 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). - :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: Any - ) -> None: - """ - :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.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. 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().__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: Any - ) -> None: - """ - :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.v2021_06_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: Any) -> None: - """ """ - 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.v2021_06_01_preview.models.TlsStatus - :ivar certificate: The certificate used to configure HTTPS for the login server. - :vartype certificate: - ~azure.mgmt.containerregistry.v2021_06_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: Any) -> None: - """ """ - 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.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. 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 - with. - :vartype scope_map_id: str - :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. 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}, - } - - _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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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. - :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.v2021_06_01_preview.models.TokenCertificate] - :ivar passwords: - :vartype passwords: - list[~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :keyword certificates: - :paramtype certificates: - list[~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenCertificate] - :keyword passwords: - :paramtype passwords: - list[~azure.mgmt.containerregistry.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_01_preview.models.TokenStatus - :ivar credentials: The credentials that can be used for authenticating the token. - :vartype credentials: - ~azure.mgmt.containerregistry.v2021_06_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: Any - ) -> None: - """ - :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.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().__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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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. Known values - are: "enabled" and "disabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2021_06_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: Any) -> None: - """ - :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 VirtualNetworkRule(_serialization.Model): - """Virtual network rule. - - All required parameters must be populated in order to send to server. - - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :vartype virtual_network_resource_id: str - """ - - _validation = { - "virtual_network_resource_id": {"required": True}, - } - - _attribute_map = { - "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, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :paramtype virtual_network_resource_id: str - """ - super().__init__(**kwargs) - self.action = action - self.virtual_network_resource_id = virtual_network_resource_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 server. - - :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.v2021_06_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.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. - '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.v2021_06_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.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}, - } - - _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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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 server. - - :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.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. - '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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.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. - '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.v2021_06_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: Any - ) -> None: - """ - :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.v2021_06_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.v2021_06_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/v2021_06_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 3aa40339ecc3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ConnectedRegistriesOperations", - "ExportPipelinesOperations", - "RegistriesOperations", - "ImportPipelinesOperations", - "Operations", - "PipelineRunsOperations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "ScopeMapsOperations", - "TokensOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 7a7d99f53b87..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_connected_registries_operations.py +++ /dev/null @@ -1,1128 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **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. - Is either a ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **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. - Is either a ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. 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 - :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.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 3e6541eff6c6..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ExportPipeline or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 3934736aa3c4..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,676 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportPipeline or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 0ef80d6319a5..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - _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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index bf448d56d535..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,674 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **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. Is either a - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PipelineRun or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index a473da6fe208..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,698 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -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, *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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index 057fdc08c2ec..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_registries_operations.py +++ /dev/null @@ -1,2038 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), - } - - _url: str = _url.format(**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_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: str = 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" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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( # pylint: disable=name-too-long - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_name_check_request, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Registry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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. Is either a - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.GenerateCredentialsParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 86d7bbd8fb72..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_replications_operations.py +++ /dev/null @@ -1,926 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -class ReplicationsOperations: - """ - .. 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:`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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Replication or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index ba5b4209c925..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_scope_maps_operations.py +++ /dev/null @@ -1,918 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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-_]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-_]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, 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: str = 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}/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-_]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -class ScopeMapsOperations: - """ - .. 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:`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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **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. Is either a - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMap or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **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. Is either a - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.ScopeMapUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index e8da80ca4858..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_tokens_operations.py +++ /dev/null @@ -1,917 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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-]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-]*$" - ), - } - - _url: str = _url.format(**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: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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, 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: str = 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}/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-]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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) - - -class TokensOperations: - """ - .. 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:`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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **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. Is either a Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Token - or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **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. Is either a - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.TokenUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index d883ed75e6e5..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/operations/_webhooks_operations.py +++ /dev/null @@ -1,1238 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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( - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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_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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_06_01_preview.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_06_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-06-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_06_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 ae876c37f272..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 = "11.0.0" +VERSION = "1.0.0b1" 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index ee6ea5301461..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2021-09-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index 4cf307fef517..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_container_registry_management_client.py +++ /dev/null @@ -1,137 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - Operations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: azure.mgmt.containerregistry.v2021_09_01.operations.RegistriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2021_09_01.operations.Operations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2021_09_01.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - 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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "2021-09-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-09-01") - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-09-01" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-09-01" - ) - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2021-09-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index 7896d99b35e8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_metadata.json +++ /dev/null @@ -1,114 +0,0 @@ -{ - "chosen_version": "2021-09-01", - "total_api_version_list": ["2021-09-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "registries": "RegistriesOperations", - "operations": "Operations", - "private_endpoint_connections": "PrivateEndpointConnectionsOperations", - "replications": "ReplicationsOperations", - "webhooks": "WebhooksOperations" - } -} 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 002cfa52056f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2021-09-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index 14b4185f41fe..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_container_registry_management_client.py +++ /dev/null @@ -1,140 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - Operations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: - """ContainerRegistryManagementClient. - - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2021_09_01.aio.operations.RegistriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2021_09_01.aio.operations.Operations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2021_09_01.aio.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - 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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "2021-09-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2021-09-01") - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-09-01" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-09-01" - ) - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2021-09-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index 914662bcf770..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "Operations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 5be1f4e14bce..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index b6304cf16941..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,536 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 64d35cc0b6f7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1463 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. 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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index e8c6f1ff06ca..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_replications_operations.py +++ /dev/null @@ -1,735 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 6436128da6ce..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,947 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index b78c8e13020c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/__init__.py +++ /dev/null @@ -1,200 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - Action, - ActionsRequired, - ConnectionStatus, - CreatedByType, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - NetworkRuleBypassOptions, - PasswordName, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) -from ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 2d4f90e5beae..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,183 +0,0 @@ -# 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 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/v2021_09_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_models_py3.py deleted file mode 100644 index 1a43b06aff05..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_models_py3.py +++ /dev/null @@ -1,2975 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - from .. import models as _models - - -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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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.v2021_09_01.models.EncryptionStatus - :ivar key_vault_properties: Key vault properties. - :vartype key_vault_properties: - ~azure.mgmt.containerregistry.v2021_09_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: Any - ) -> None: - """ - :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.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().__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.v2021_09_01.models.ErrorResponseBody - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponseBody"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs: Any) -> None: - """ - :keyword error: Azure container registry build API error body. - :paramtype error: ~azure.mgmt.containerregistry.v2021_09_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 server. - - :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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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: Any) -> None: # 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.v2021_09_01.models.EventRequestMessage - :ivar event_response_message: The event response message received from the service URI. - :vartype event_response_message: - ~azure.mgmt.containerregistry.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_01.models.EventRequestMessage - :keyword event_response_message: The event response message received from the service URI. - :paramtype event_response_message: - ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_01.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_01.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_01.models.ExportPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs: Any) -> None: - """ - :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().__init__(**kwargs) - self.status = status - - -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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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.v2021_09_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 server. - - :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). - :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.v2021_09_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: Any - ) -> None: - """ - :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). - :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.v2021_09_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 server. - - :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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: 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: Any - ) -> None: - """ - :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: 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: Any) -> None: - """ - :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 server. - - :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}, - } - - _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: Any - ) -> None: - """ - :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().__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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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. # pylint: disable=line-too-long - :paramtype is_data_action: bool - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2021_09_01.models.OperationMetricSpecificationDefinition] - :ivar log_specifications: A list of Azure Monitoring log definitions. - :vartype log_specifications: - list[~azure.mgmt.containerregistry.v2021_09_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: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2021_09_01.models.OperationMetricSpecificationDefinition] - :keyword log_specifications: A list of Azure Monitoring log definitions. - :paramtype log_specifications: - list[~azure.mgmt.containerregistry.v2021_09_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: Any) -> None: - """ - :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.v2021_09_01.models.QuarantinePolicy - :ivar trust_policy: The content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2021_09_01.models.TrustPolicy - :ivar retention_policy: The retention policy for a container registry. - :vartype retention_policy: ~azure.mgmt.containerregistry.v2021_09_01.models.RetentionPolicy - :ivar export_policy: The export policy for a container registry. - :vartype export_policy: ~azure.mgmt.containerregistry.v2021_09_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: Any - ) -> None: - """ - :keyword quarantine_policy: The quarantine policy for a container registry. - :paramtype quarantine_policy: ~azure.mgmt.containerregistry.v2021_09_01.models.QuarantinePolicy - :keyword trust_policy: The content trust policy for a container registry. - :paramtype trust_policy: ~azure.mgmt.containerregistry.v2021_09_01.models.TrustPolicy - :keyword retention_policy: The retention policy for a container registry. - :paramtype retention_policy: ~azure.mgmt.containerregistry.v2021_09_01.models.RetentionPolicy - :keyword export_policy: The export policy for a container registry. - :paramtype export_policy: ~azure.mgmt.containerregistry.v2021_09_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: Any) -> None: # 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.v2021_09_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: Any) -> None: - """ """ - 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.v2021_09_01.models.SystemData - :ivar private_endpoint: The resource of private endpoint. - :vartype private_endpoint: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private endpoint. - :paramtype private_endpoint: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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.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. 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"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.ConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, - **kwargs: Any - ) -> None: - """ - :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. Known values are: "None" and "Recreate". - :paramtype actions_required: str or - ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_01.models.PolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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().__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 server. - - :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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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().__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 server. - - :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.v2021_09_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: Any) -> None: - """ - :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): - """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 server. - - :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.v2021_09_01.models.SystemData - :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 - :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.v2021_09_01.models.ProvisioningState - :ivar status: The status of the container registry at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_01.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2021_09_01.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_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.v2021_09_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.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"}, - } - - 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: Any - ) -> None: - """ - :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.v2021_09_01.models.Sku - :keyword identity: The identity of the container registry. - :paramtype identity: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_01.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2021_09_01.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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.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"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__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.v2021_09_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.v2021_09_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.v2021_09_01.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2021_09_01.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.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"}, - } - - 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: Any - ) -> None: - """ - :keyword identity: The identity of the container registry. - :paramtype identity: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_01.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2021_09_01.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: ~azure.mgmt.containerregistry.v2021_09_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.v2021_09_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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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.v2021_09_01.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2021_09_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 server. - - :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.v2021_09_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.v2021_09_01.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2021_09_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.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}, - } - - _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: Any - ) -> None: - """ - :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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_01.models.PolicyStatus - """ - super().__init__(**kwargs) - self.days = days - self.last_updated_time = None - self.status = status - - -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 server. - - :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. 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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: - """ - :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().__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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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 server. - - :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: Any) -> None: # 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.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. 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). - :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: Any - ) -> None: - """ - :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.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. 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().__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: Any - ) -> None: - """ - :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 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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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. Known values - are: "enabled" and "disabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2021_09_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: Any) -> None: - """ - :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 server. - - :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.v2021_09_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.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. - '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.v2021_09_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.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}, - } - - _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: Any - ) -> None: - """ - :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.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' - 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.v2021_09_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 server. - - :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.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. - '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.v2021_09_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: Any - ) -> None: - """ - :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.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' - 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.v2021_09_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.v2021_09_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: Any - ) -> None: - """ - :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.v2021_09_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.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. - '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.v2021_09_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: Any - ) -> None: - """ - :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.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' - 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.v2021_09_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/v2021_09_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 914662bcf770..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "RegistriesOperations", - "Operations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index cc51d8906bbf..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_operations.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - _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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 47f93cee874f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,682 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 7ee9dc799e2c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_registries_operations.py +++ /dev/null @@ -1,1856 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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( # pylint: disable=name-too-long - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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"), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2021_09_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2021_09_01.models.Registry or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. 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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 91eacf8b38ea..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_replications_operations.py +++ /dev/null @@ -1,908 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2021_09_01.models.Replication or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.ReplicationUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index fca0b49f5566..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/operations/_webhooks_operations.py +++ /dev/null @@ -1,1208 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_09_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_09_01.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_09_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2021-09-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_09_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 591424576629..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2021-12-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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/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 deleted file mode 100644 index 6fc1f3064583..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_container_registry_management_client.py +++ /dev/null @@ -1,184 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -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, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.ConnectedRegistriesOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2021_12_01_preview.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2021_12_01_preview.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: azure.mgmt.containerregistry.v2021_12_01_preview.operations.TokensOperations - :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. Required. - :type credential: ~azure.core.credentials.TokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index 83c46a8ba1b1..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_metadata.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "chosen_version": "2021-12-01-preview", - "total_api_version_list": ["2021-12-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The Microsoft Azure subscription ID. Required.", - "docstring_type": "str", - "required": true, - "method_location": "positional" - } - }, - "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 Microsoft Azure subscription ID. 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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "connected_registries": "ConnectedRegistriesOperations", - "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/v2021_12_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_patch.py deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 92f81413652c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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 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: - api_version: str = kwargs.pop("api_version", "2021-12-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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/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 deleted file mode 100644 index 11a29cee38cb..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_container_registry_management_client.py +++ /dev/null @@ -1,187 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -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, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.ConnectedRegistriesOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: - azure.mgmt.containerregistry.v2021_12_01_preview.aio.operations.TokensOperations - :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. Required. - :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :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 - :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 - :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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2021-12-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) 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 deleted file mode 100644 index 17dbc073e01b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/_patch.py +++ /dev/null @@ -1,32 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# -# 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. -# -# -------------------------------------------------------------------------- - - -# 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 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 deleted file mode 100644 index 3aa40339ecc3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ConnectedRegistriesOperations", - "ExportPipelinesOperations", - "RegistriesOperations", - "ImportPipelinesOperations", - "Operations", - "PipelineRunsOperations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "ScopeMapsOperations", - "TokensOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 06f57b2e6c39..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_connected_registries_operations.py +++ /dev/null @@ -1,887 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistry"]: - # pylint: disable=line-too-long - """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. 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 - :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.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **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. - Is either a ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **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. - Is either a ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 83e8e8e96867..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,548 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._export_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExportPipeline"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index a6320c6854c2..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,548 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._import_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImportPipeline"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 2f917979e2b3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - # pylint: disable=line-too-long - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 1650e5585319..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,543 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._pipeline_runs_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **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. Is either a - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 8679f8265b94..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,551 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index b946d02a9e70..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1707 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_async - async def check_name_availability( - self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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_create( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_private_link_resources( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResource"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. 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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(regenerate_credential_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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. Is either a - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 64d52eeeebc4..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_replications_operations.py +++ /dev/null @@ -1,753 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index b9b5c2db2d9f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_scope_maps_operations.py +++ /dev/null @@ -1,758 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **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. Is either a - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **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. Is either a - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 756784027519..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_tokens_operations.py +++ /dev/null @@ -1,749 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._tokens_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **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. Is either a Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token - or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **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. Is either a - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 240fdf8c623a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,969 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 01c03f937efd..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/__init__.py +++ /dev/null @@ -1,310 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - 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 ._patch import __all__ as _patch_all -from ._patch 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", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index 51a3b9c4423a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,293 +0,0 @@ -# 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 virtual network 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 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 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/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 deleted file mode 100644 index 7d76df30d50e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_models_py3.py +++ /dev/null @@ -1,4903 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - 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.v2021_12_01_preview.models.ActivationStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - 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: Any) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 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.v2021_12_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class ConnectedRegistry(ProxyResource): - """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.v2021_12_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.v2021_12_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.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. 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. - :vartype last_activity_time: ~datetime.datetime - :ivar activation: The activation properties of the connected registry. - :vartype activation: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ActivationProperties - :ivar parent: The parent of the connected registry. - :vartype parent: ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_01_preview.models.LoginServerProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.LoggingProperties - :ivar status_details: The list of current statuses of the connected registry. - :vartype status_details: - list[~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_01_preview.models.ConnectedRegistryMode - :keyword parent: The parent of the connected registry. - :paramtype parent: ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_01_preview.models.LoginServerProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_01_preview.models.SyncUpdateProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :keyword sync_properties: The sync properties of the connected registry with its parent. - :paramtype sync_properties: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.SyncUpdateProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2021_12_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 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.v2021_12_01_preview.models.EncryptionStatus - :ivar key_vault_properties: Key vault properties. - :vartype key_vault_properties: - ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :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.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().__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.v2021_12_01_preview.models.ErrorResponseBody - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponseBody"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs: Any) -> None: - """ - :keyword error: Azure container registry build API error body. - :paramtype error: ~azure.mgmt.containerregistry.v2021_12_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 server. - - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any) -> None: # 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.v2021_12_01_preview.models.EventRequestMessage - :ivar event_response_message: The event response message received from the service URI. - :vartype event_response_message: - ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_01_preview.models.EventRequestMessage - :keyword event_response_message: The event response message received from the service URI. - :paramtype event_response_message: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_01_preview.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_01_preview.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_01_preview.models.IdentityProperties - :ivar target: The target properties of the export pipeline. - :vartype target: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipelineTargetProperties - :ivar options: The list of all options configured for the pipeline. - :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. 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}, - } - - _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: Any - ) -> None: - """ - :keyword location: The location of the export pipeline. - :paramtype location: str - :keyword identity: The identity of the export pipeline. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.IdentityProperties - :keyword target: The target properties of the export pipeline. - :paramtype target: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipelineTargetProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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 server. - - :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: Any - ) -> None: - """ - :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.v2021_12_01_preview.models.ExportPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs: Any) -> None: - """ - :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().__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.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"}, - } - - def __init__( - self, - *, - token_id: Optional[str] = None, - expiry: Optional[datetime.datetime] = None, - name: Optional[Union[str, "_models.TokenPasswordName"]] = None, - **kwargs: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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 server. - - :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). - :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.v2021_12_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: Any - ) -> None: - """ - :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). - :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.v2021_12_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.v2021_12_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.v2021_12_01_preview.models.IdentityProperties - :ivar source: The source properties of the import pipeline. - :vartype source: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipelineSourceProperties - :ivar trigger: The properties that describe the trigger of the import pipeline. - :vartype trigger: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineTriggerProperties - :ivar options: The list of all options configured for the pipeline. - :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. 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}, - } - - _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: Any - ) -> None: - """ - :keyword location: The location of the import pipeline. - :paramtype location: str - :keyword identity: The identity of the import pipeline. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.IdentityProperties - :keyword source: The source properties of the import pipeline. - :paramtype source: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipelineSourceProperties - :keyword trigger: The properties that describe the trigger of the import pipeline. - :paramtype trigger: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineTriggerProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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 server. - - :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: 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: Any - ) -> None: - """ - :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: 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 server. - - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: 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: Optional[Union[str, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: 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: Any) -> None: - """ - :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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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. - Known values are: "Enabled" and "Disabled". - :paramtype audit_log_status: str or - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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: Any) -> None: - """ """ - 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 server. - - :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. - :vartype virtual_network_rules: - list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.VirtualNetworkRule] - :ivar ip_rules: The IP ACL rules. - :vartype ip_rules: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.IPRule] - """ - - _validation = { - "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]"}, - } - - def __init__( - self, - *, - default_action: Union[str, "_models.DefaultAction"] = "Allow", - virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, - ip_rules: Optional[List["_models.IPRule"]] = None, - **kwargs: Any - ) -> None: - """ - :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. - :paramtype virtual_network_rules: - list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.VirtualNetworkRule] - :keyword ip_rules: The IP ACL rules. - :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.IPRule] - """ - super().__init__(**kwargs) - self.default_action = default_action - self.virtual_network_rules = virtual_network_rules - 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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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. # pylint: disable=line-too-long - :paramtype is_data_action: bool - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2021_12_01_preview.models.OperationMetricSpecificationDefinition] - :ivar log_specifications: A list of Azure Monitoring log definitions. - :vartype log_specifications: - list[~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationMetricSpecificationDefinition] - :keyword log_specifications: A list of Azure Monitoring log definitions. - :paramtype log_specifications: - list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.OperationLogSpecificationDefinition] - """ - super().__init__(**kwargs) - self.metric_specifications = metric_specifications - self.log_specifications = log_specifications - - -class ParentProperties(_serialization.Model): - """The properties of the connected registry parent. - - All required parameters must be populated in order to send to server. - - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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.v2021_12_01_preview.models.ProvisioningState - :ivar request: The request parameters for a pipeline run. - :vartype request: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRunRequest - :ivar response: The response of a pipeline run. - :vartype response: ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :keyword request: The request parameters for a pipeline run. - :paramtype request: ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_01_preview.models.PipelineRunSourceProperties - :ivar target: The target properties of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_01_preview.models.PipelineRunSourceProperties - :keyword target: The target properties of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_01_preview.models.ImportPipelineSourceProperties - :ivar target: The target of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_01_preview.models.ImportPipelineSourceProperties - :keyword target: The target of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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().__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.v2021_12_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: Any - ) -> None: - """ - :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().__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: Any) -> None: - """ - :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 server. - - :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}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs: Any) -> None: - """ - :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().__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.v2021_12_01_preview.models.PipelineSourceTriggerDescriptor - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger that caused the pipeline run. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_01_preview.models.PipelineSourceTriggerProperties - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger properties of the pipeline. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_01_preview.models.QuarantinePolicy - :ivar trust_policy: The content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TrustPolicy - :ivar retention_policy: The retention policy for a container registry. - :vartype retention_policy: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RetentionPolicy - :ivar export_policy: The export policy for a container registry. - :vartype export_policy: ~azure.mgmt.containerregistry.v2021_12_01_preview.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: Any - ) -> None: - """ - :keyword quarantine_policy: The quarantine policy for a container registry. - :paramtype quarantine_policy: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.QuarantinePolicy - :keyword trust_policy: The content trust policy for a container registry. - :paramtype trust_policy: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TrustPolicy - :keyword retention_policy: The retention policy for a container registry. - :paramtype retention_policy: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RetentionPolicy - :keyword export_policy: The export policy for a container registry. - :paramtype export_policy: ~azure.mgmt.containerregistry.v2021_12_01_preview.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: Any) -> None: # 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.v2021_12_01_preview.models.SystemData - :ivar private_endpoint: The resource of private endpoint. - :vartype private_endpoint: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private endpoint. - :paramtype private_endpoint: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.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. 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"}, - } - - def __init__( - self, - *, - status: Optional[Union[str, "_models.ConnectionStatus"]] = None, - description: Optional[str] = None, - actions_required: Optional[Union[str, "_models.ActionsRequired"]] = None, - **kwargs: Any - ) -> None: - """ - :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. Known values are: "None" and "Recreate". - :paramtype actions_required: str or - ~azure.mgmt.containerregistry.v2021_12_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: Any) -> None: - """ - :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.v2021_12_01_preview.models.PolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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().__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 server. - - :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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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().__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 server. - - :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.v2021_12_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: Any) -> None: - """ - :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): - """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 server. - - :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.v2021_12_01_preview.models.SystemData - :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 - :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.v2021_12_01_preview.models.ProvisioningState - :ivar status: The status of the container registry at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_01_preview.models.Sku - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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.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"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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().__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.v2021_12_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.v2021_12_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.v2021_12_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_01_preview.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2021_12_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 server. - - :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.v2021_12_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.v2021_12_01_preview.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2021_12_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.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}, - } - - _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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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: Any - ) -> None: - """ - :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 server. - - :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. 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}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - "tier": {"key": "tier", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs: Any) -> None: - """ - :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().__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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.code = None - self.description = None - self.timestamp = None - self.correlation_id = None - - -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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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.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. 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). - :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: Any - ) -> None: - """ - :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.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. 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().__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: Any - ) -> None: - """ - :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.v2021_12_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: Any) -> None: - """ """ - 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.v2021_12_01_preview.models.TlsStatus - :ivar certificate: The certificate used to configure HTTPS for the login server. - :vartype certificate: - ~azure.mgmt.containerregistry.v2021_12_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: Any) -> None: - """ """ - 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.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. 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 - with. - :vartype scope_map_id: str - :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. 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}, - } - - _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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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. - :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.v2021_12_01_preview.models.TokenCertificate] - :ivar passwords: - :vartype passwords: - list[~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :keyword certificates: - :paramtype certificates: - list[~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenCertificate] - :keyword passwords: - :paramtype passwords: - list[~azure.mgmt.containerregistry.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_01_preview.models.TokenStatus - :ivar credentials: The credentials that can be used for authenticating the token. - :vartype credentials: - ~azure.mgmt.containerregistry.v2021_12_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: Any - ) -> None: - """ - :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.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().__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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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. Known values - are: "enabled" and "disabled". - :paramtype status: str or ~azure.mgmt.containerregistry.v2021_12_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: Any) -> None: - """ - :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 VirtualNetworkRule(_serialization.Model): - """Virtual network rule. - - All required parameters must be populated in order to send to server. - - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :vartype virtual_network_resource_id: str - """ - - _validation = { - "virtual_network_resource_id": {"required": True}, - } - - _attribute_map = { - "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, "_models.Action"]] = None, **kwargs: Any - ) -> None: - """ - :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: Resource ID of a subnet, for example: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. # pylint: disable=line-too-long - Required. - :paramtype virtual_network_resource_id: str - """ - super().__init__(**kwargs) - self.action = action - self.virtual_network_resource_id = virtual_network_resource_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 server. - - :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.v2021_12_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.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. - '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.v2021_12_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.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}, - } - - _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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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 server. - - :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.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. - '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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.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. - '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.v2021_12_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: Any - ) -> None: - """ - :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.v2021_12_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.v2021_12_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/v2021_12_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 3aa40339ecc3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/__init__.py +++ /dev/null @@ -1,45 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ConnectedRegistriesOperations", - "ExportPipelinesOperations", - "RegistriesOperations", - "ImportPipelinesOperations", - "Operations", - "PipelineRunsOperations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "ScopeMapsOperations", - "TokensOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_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 deleted file mode 100644 index c591c53cfd3a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_connected_registries_operations.py +++ /dev/null @@ -1,1128 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$", - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. 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 - :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.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_create( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **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. - Is either a ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **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. - Is either a ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 8f146ca3b883..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,686 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ExportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 0fed20a6a95a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,686 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: - ~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 - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportPipeline or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 6847340a8dda..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - _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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index afc78906e899..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,684 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **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. Is either a - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PipelineRun or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 8aeab6516cf3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,698 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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}/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" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - private_endpoint_connection_name: str, - private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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. - Is either a PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateEndpointConnection or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 1b71e71cd676..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_registries_operations.py +++ /dev/null @@ -1,2136 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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" - ) - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str", min_length=1), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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( # pylint: disable=name-too-long - 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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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"), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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. Is either a ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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.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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :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.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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: ~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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Registry or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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. Is either - a RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the container registry - belongs. 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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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. Is either a RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(regenerate_credential_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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 - :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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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. Is either a - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.GenerateCredentialsParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index e07a6f0f69b9..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_replications_operations.py +++ /dev/null @@ -1,926 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **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. Is either a Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Replication or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **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. Is either a - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index c719f296e1f4..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_scope_maps_operations.py +++ /dev/null @@ -1,929 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-_]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-_]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-_]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-_]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **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. Is either a - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMap or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **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. Is either a - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.ScopeMapUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 9230ba672186..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_tokens_operations.py +++ /dev/null @@ -1,928 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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-]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 to which the 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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # 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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **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. Is either a Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Token - or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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_update( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **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. Is either a - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.TokenUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 56f77a295db4..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/operations/_webhooks_operations.py +++ /dev/null @@ -1,1238 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "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: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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: str = 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}/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]*$" - ), - } - - _url: str = _url.format(**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.v2021_12_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 to which the container registry - belongs. Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :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.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **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. Is either a - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookCreateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **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. Is either a - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2021_12_01_preview.models.WebhookUpdateParameters or IO[bytes] - :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: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "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) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 to which the 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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 to which the 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 - :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.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 to which the 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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2021_12_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2021-12-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2021_12_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file 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 ae876c37f272..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 = "11.0.0" +VERSION = "1.0.0b1" 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 deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index 6055e64c5512..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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: - api_version: str = 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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 deleted file mode 100644 index bc8a3c359def..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_container_registry_management_client.py +++ /dev/null @@ -1,147 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -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: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "2022-12-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2022-12-01") - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01" - ) - self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize, "2022-12-01") - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2022-12-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index d0eabbd54e5b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_metadata.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "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, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_version.py deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" 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 deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_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 deleted file mode 100644 index cdbe63393b00..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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: - api_version: str = 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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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 deleted file mode 100644 index 20ce0e18ec6f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_container_registry_management_client.py +++ /dev/null @@ -1,151 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -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: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "2022-12-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2022-12-01") - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2022-12-01" - ) - self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize, "2022-12-01") - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2022-12-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index bdd70552b237..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch 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__]) # pyright: ignore -_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 deleted file mode 100644 index 218145afca21..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index ae4eba043343..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,551 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 99d90748fac7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1698 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 596c1f31d663..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_replications_operations.py +++ /dev/null @@ -1,759 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.ReplicationUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index d7eb925ad4d5..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_scope_maps_operations.py +++ /dev/null @@ -1,765 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMapUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 6422b1d450be..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_tokens_operations.py +++ /dev/null @@ -1,757 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._tokens_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.Token or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.TokenUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 60f36db7d18b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,971 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookCreateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index 424d3ddaf3f3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/__init__.py +++ /dev/null @@ -1,230 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - 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, -) -from ._patch import __all__ as _patch_all -from ._patch 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__]) # pyright: ignore -_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 deleted file mode 100644 index d7d263b0717e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,204 +0,0 @@ -# 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 deleted file mode 100644 index 53d07f8c8c31..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_models_py3.py +++ /dev/null @@ -1,3499 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - 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: Any) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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: Any) -> None: # 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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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. # pylint: disable=line-too-long - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any) -> None: # 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: Any) -> None: - """ """ - 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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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): - """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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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 server. - - :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: Any) -> None: # 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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index bdd70552b237..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/__init__.py +++ /dev/null @@ -1,37 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch 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__]) # pyright: ignore -_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 deleted file mode 100644 index 0d60e89fbdfd..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_operations.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) 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 deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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 deleted file mode 100644 index 8563805b04f2..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,704 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateEndpointConnection or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore 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 deleted file mode 100644 index 354d249ef466..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_registries_operations.py +++ /dev/null @@ -1,2148 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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( # pylint: disable=name-too-long - 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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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 - :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[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2022_12_01.models.Registry or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.GenerateCredentialsParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 528378a00e79..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_replications_operations.py +++ /dev/null @@ -1,940 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2022_12_01.models.Replication or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.ReplicationUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index ea51e5ba8eaa..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_scope_maps_operations.py +++ /dev/null @@ -1,943 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMap or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.ScopeMapUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 2517c0d79dd4..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_tokens_operations.py +++ /dev/null @@ -1,937 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2022_12_01.models.Token or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.TokenUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) 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 deleted file mode 100644 index 5f3607c75edc..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/operations/_webhooks_operations.py +++ /dev/null @@ -1,1246 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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: str = 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 = _url.format(**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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookCreateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2022_12_01.models.WebhookUpdateParameters or IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2022-12-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2022_12_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore 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 deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2022_12_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# 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/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_01_01_preview/_version.py index ae876c37f272..e5754a47ce68 100644 --- 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 @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "11.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/__init__.py deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_configuration.py deleted file mode 100644 index 070a37b5a9bd..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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-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: - api_version: str = kwargs.pop("api_version", "2023-06-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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_06_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_container_registry_management_client.py deleted file mode 100644 index e103fc4250ba..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_container_registry_management_client.py +++ /dev/null @@ -1,212 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - ArchiveVersionsOperations, - ArchivesOperations, - CacheRulesOperations, - ConnectedRegistriesOperations, - CredentialSetsOperations, - ExportPipelinesOperations, - ImportPipelinesOperations, - Operations, - PipelineRunsOperations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - ScopeMapsOperations, - TokensOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar archives: ArchivesOperations operations - :vartype archives: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.ArchivesOperations - :ivar archive_versions: ArchiveVersionsOperations operations - :vartype archive_versions: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.ArchiveVersionsOperations - :ivar cache_rules: CacheRulesOperations operations - :vartype cache_rules: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.CacheRulesOperations - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.ConnectedRegistriesOperations - :ivar credential_sets: CredentialSetsOperations operations - :vartype credential_sets: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.CredentialSetsOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2023_06_06_preview.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2023_06_06_preview.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: azure.mgmt.containerregistry.v2023_06_06_preview.operations.TokensOperations - :ivar webhooks: WebhooksOperations operations - :vartype webhooks: - azure.mgmt.containerregistry.v2023_06_06_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-06-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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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.archives = ArchivesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.archive_versions = ArchiveVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.cache_rules = CacheRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.credential_sets = CredentialSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_metadata.json deleted file mode 100644 index c08853cdc96a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_metadata.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "chosen_version": "2023-06-01-preview", - "total_api_version_list": ["2023-06-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "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, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "archives": "ArchivesOperations", - "archive_versions": "ArchiveVersionsOperations", - "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_06_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_06_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_version.py deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/__init__.py deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_configuration.py deleted file mode 100644 index 477a0b3bafc9..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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-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: - api_version: str = kwargs.pop("api_version", "2023-06-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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_06_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_container_registry_management_client.py deleted file mode 100644 index 23f1c7c02cbc..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_container_registry_management_client.py +++ /dev/null @@ -1,215 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - ArchiveVersionsOperations, - ArchivesOperations, - CacheRulesOperations, - ConnectedRegistriesOperations, - CredentialSetsOperations, - ExportPipelinesOperations, - ImportPipelinesOperations, - Operations, - PipelineRunsOperations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - ScopeMapsOperations, - TokensOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar archives: ArchivesOperations operations - :vartype archives: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.ArchivesOperations - :ivar archive_versions: ArchiveVersionsOperations operations - :vartype archive_versions: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.ArchiveVersionsOperations - :ivar cache_rules: CacheRulesOperations operations - :vartype cache_rules: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.CacheRulesOperations - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.ConnectedRegistriesOperations - :ivar credential_sets: CredentialSetsOperations operations - :vartype credential_sets: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.CredentialSetsOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: - azure.mgmt.containerregistry.v2023_06_06_preview.aio.operations.TokensOperations - :ivar webhooks: WebhooksOperations operations - :vartype webhooks: - azure.mgmt.containerregistry.v2023_06_06_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-06-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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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.archives = ArchivesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.archive_versions = ArchiveVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.cache_rules = CacheRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.credential_sets = CredentialSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-06-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_06_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/__init__.py deleted file mode 100644 index 07d4637faf87..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._archives_operations import ArchivesOperations # type: ignore -from ._archive_versions_operations import ArchiveVersionsOperations # type: ignore -from ._cache_rules_operations import CacheRulesOperations # type: ignore -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._credential_sets_operations import CredentialSetsOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ArchivesOperations", - "ArchiveVersionsOperations", - "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__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_archive_versions_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_archive_versions_operations.py deleted file mode 100644 index 38b8efc90e46..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_archive_versions_operations.py +++ /dev/null @@ -1,525 +0,0 @@ -# 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, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._archive_versions_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ArchiveVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_06_06_preview.aio.ContainerRegistryManagementClient`'s - :attr:`archive_versions` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ArchiveVersion"]: - # pylint: disable=line-too-long - """Lists all archive versions for the specified container registry, repository type and archive - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: An iterator like instance of either ArchiveVersion or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveVersionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveVersionListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> _models.ArchiveVersion: - """Gets the properties of the archive version. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: ArchiveVersion or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("ArchiveVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.ArchiveVersion]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: An instance of AsyncLROPoller that returns either ArchiveVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ArchiveVersion", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ArchiveVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ArchiveVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a archive version 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_archives_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_archives_operations.py deleted file mode 100644 index 913e957d1ace..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_archives_operations.py +++ /dev/null @@ -1,738 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._archives_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ArchivesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_06_06_preview.aio.ContainerRegistryManagementClient`'s - :attr:`archives` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, **kwargs: Any - ) -> AsyncIterable["_models.Archive"]: - """Lists all archives for the specified container registry and package type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :return: An iterator like instance of either Archive or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace_async - async def get( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> _models.Archive: - """Gets the properties of the archive. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_create_parameters, (IOBase, bytes)): - _content = archive_create_parameters - else: - _json = self._serialize.body(archive_create_parameters, "Archive") - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: _models.Archive, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Archive or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Archive or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Is either a Archive - type or a IO[bytes] type. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Archive or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - package_type=package_type, - archive_name=archive_name, - archive_create_parameters=archive_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Archive", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Archive].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Archive]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: _models.ArchiveUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: Union[_models.ArchiveUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Is either a - ArchiveUpdateParameters type or a IO[bytes] type. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveUpdateParameters or IO[bytes] - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_update_parameters, (IOBase, bytes)): - _content = archive_update_parameters - else: - _json = self._serialize.body(archive_update_parameters, "ArchiveUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_cache_rules_operations.py deleted file mode 100644 index b2e7c29a86f1..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_cache_rules_operations.py +++ /dev/null @@ -1,782 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CacheRule or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CacheRule or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_create_parameters: Union[_models.CacheRule, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - CacheRule type or a IO[bytes] type. Required. - :type cache_rule_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRule or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - CacheRuleUpdateParameters type or a IO[bytes] type. Required. - :type cache_rule_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRuleUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_connected_registries_operations.py deleted file mode 100644 index 6e3e3e53b864..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_connected_registries_operations.py +++ /dev/null @@ -1,917 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistry"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_06_06_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 - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistry or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_credential_sets_operations.py deleted file mode 100644 index a1f9d9c358b8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_credential_sets_operations.py +++ /dev/null @@ -1,789 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CredentialSet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CredentialSet or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_create_parameters: Union[_models.CredentialSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 CredentialSet type or a IO[bytes] type. Required. - :type credential_set_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 CredentialSetUpdateParameters type or a IO[bytes] type. Required. - :type credential_set_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSetUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_export_pipelines_operations.py deleted file mode 100644 index 028af78906e1..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._export_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExportPipeline"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either ExportPipeline or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipeline or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_import_pipelines_operations.py deleted file mode 100644 index b742ff6de07f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._import_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImportPipeline"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either ImportPipeline or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipeline or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_operations.py deleted file mode 100644 index e58529299d9d..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - # pylint: disable=line-too-long - """Lists all of the available Azure Container Registry REST API operations. - - :return: An iterator like instance of either OperationDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_06_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_pipeline_runs_operations.py deleted file mode 100644 index 7243d193ff82..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,558 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._pipeline_runs_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either PipelineRun or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineRun or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index bf45f3605ff2..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,566 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_06_06_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 - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_registries_operations.py deleted file mode 100644 index 895591ac5f15..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1743 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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_06_06_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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_private_link_resources( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResource"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_06_06_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 - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.GenerateCredentialsParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_replications_operations.py deleted file mode 100644 index ea873d9d6106..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_replications_operations.py +++ /dev/null @@ -1,777 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Replication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Replication or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ReplicationUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_scope_maps_operations.py deleted file mode 100644 index 3706eb9a925d..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_scope_maps_operations.py +++ /dev/null @@ -1,782 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMap or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMapUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_tokens_operations.py deleted file mode 100644 index b219ac958504..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_tokens_operations.py +++ /dev/null @@ -1,773 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._tokens_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Token or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Token - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.TokenUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_webhooks_operations.py deleted file mode 100644 index 2049a0eb2c7d..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,993 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Webhook or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.WebhookCreateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.WebhookUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either Event or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/__init__.py deleted file mode 100644 index 94b57b4d7169..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/__init__.py +++ /dev/null @@ -1,358 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ActivationProperties, - ActiveDirectoryObject, - Actor, - Archive, - ArchiveListResult, - ArchivePackageSourceProperties, - ArchiveProperties, - ArchiveUpdateParameters, - ArchiveVersion, - ArchiveVersionListResult, - AuthCredential, - AzureADAuthenticationAsArmPolicy, - CacheRule, - CacheRuleUpdateParameters, - CacheRulesListResult, - CallbackConfig, - ConnectedRegistry, - ConnectedRegistryListResult, - ConnectedRegistryUpdateParameters, - CredentialHealth, - CredentialSet, - CredentialSetListResult, - CredentialSetUpdateParameters, - DebianArchivePackageSourceProperties, - DebianArchiveProperties, - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - Action, - ActionsRequired, - ActivationStatus, - AuditLogStatus, - AzureADAuthenticationAsArmPolicyStatus, - CertificateType, - ConnectedRegistryMode, - ConnectionState, - ConnectionStatus, - CreatedByType, - CredentialHealthStatus, - CredentialName, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - LogLevel, - NetworkRuleBypassOptions, - PackageSourceType, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TlsStatus, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivationProperties", - "ActiveDirectoryObject", - "Actor", - "Archive", - "ArchiveListResult", - "ArchivePackageSourceProperties", - "ArchiveProperties", - "ArchiveUpdateParameters", - "ArchiveVersion", - "ArchiveVersionListResult", - "AuthCredential", - "AzureADAuthenticationAsArmPolicy", - "CacheRule", - "CacheRuleUpdateParameters", - "CacheRulesListResult", - "CallbackConfig", - "ConnectedRegistry", - "ConnectedRegistryListResult", - "ConnectedRegistryUpdateParameters", - "CredentialHealth", - "CredentialSet", - "CredentialSetListResult", - "CredentialSetUpdateParameters", - "DebianArchivePackageSourceProperties", - "DebianArchiveProperties", - "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", - "PackageSourceType", - "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__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/_container_registry_management_client_enums.py deleted file mode 100644 index 1ac71a8a0af3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,319 +0,0 @@ -# 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 PackageSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of package source for a archive.""" - - REMOTE = "remote" - - -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): - """The provisioning state of the archive at the time the operation was called.""" - - 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_06_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/_models_py3.py deleted file mode 100644 index 37c38da88a48..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/_models_py3.py +++ /dev/null @@ -1,5776 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - 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_06_06_preview.models.ActivationStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - 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: Any) -> None: - """ - :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: Any) -> None: - """ - :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 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_06_06_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class Archive(ProxyResource): - """An object that represents a archive 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_06_06_preview.models.SystemData - :ivar package_source: The package source of the archive. - :vartype package_source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchivePackageSourceProperties - :ivar published_version: The published version of the archive. - :vartype published_version: str - :ivar repository_endpoint_prefix: - :vartype repository_endpoint_prefix: str - :ivar repository_endpoint: - :vartype repository_endpoint: str - :ivar provisioning_state: The provisioning state of the archive 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_06_06_preview.models.ProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "repository_endpoint": {"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"}, - "package_source": {"key": "properties.packageSource", "type": "ArchivePackageSourceProperties"}, - "published_version": {"key": "properties.publishedVersion", "type": "str"}, - "repository_endpoint_prefix": {"key": "properties.repositoryEndpointPrefix", "type": "str"}, - "repository_endpoint": {"key": "properties.repositoryEndpoint", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - package_source: Optional["_models.ArchivePackageSourceProperties"] = None, - published_version: Optional[str] = None, - repository_endpoint_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_source: The package source of the archive. - :paramtype package_source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchivePackageSourceProperties - :keyword published_version: The published version of the archive. - :paramtype published_version: str - :keyword repository_endpoint_prefix: - :paramtype repository_endpoint_prefix: str - """ - super().__init__(**kwargs) - self.package_source = package_source - self.published_version = published_version - self.repository_endpoint_prefix = repository_endpoint_prefix - self.repository_endpoint = None - self.provisioning_state = None - - -class ArchiveListResult(_serialization.Model): - """The result of a request to list archives for a container registry. - - :ivar value: The list of archives. Since this list may be incomplete, the nextLink field should - be used to request the next list of distributions. - :vartype value: list[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :ivar next_link: The URI that can be used to request the next list of archives. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Archive]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Archive"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of archives. Since this list may be incomplete, the nextLink field - should be used to request the next list of distributions. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :keyword next_link: The URI that can be used to request the next list of archives. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ArchivePackageSourceProperties(_serialization.Model): - """The properties of the archive package source. - - :ivar type: The type of package source for a archive. "remote" - :vartype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PackageSourceType - :ivar url: The external repository url. - :vartype url: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "url": {"key": "url", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.PackageSourceType"]] = None, - url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of package source for a archive. "remote" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PackageSourceType - :keyword url: The external repository url. - :paramtype url: str - """ - super().__init__(**kwargs) - self.type = type - self.url = url - - -class ArchiveProperties(_serialization.Model): - """The properties of a archive. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar package_source: The package source of the archive. - :vartype package_source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchivePackageSourceProperties - :ivar published_version: The published version of the archive. - :vartype published_version: str - :ivar repository_endpoint_prefix: - :vartype repository_endpoint_prefix: str - :ivar repository_endpoint: - :vartype repository_endpoint: str - :ivar provisioning_state: The provisioning state of the archive 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_06_06_preview.models.ProvisioningState - """ - - _validation = { - "repository_endpoint": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "package_source": {"key": "packageSource", "type": "ArchivePackageSourceProperties"}, - "published_version": {"key": "publishedVersion", "type": "str"}, - "repository_endpoint_prefix": {"key": "repositoryEndpointPrefix", "type": "str"}, - "repository_endpoint": {"key": "repositoryEndpoint", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - package_source: Optional["_models.ArchivePackageSourceProperties"] = None, - published_version: Optional[str] = None, - repository_endpoint_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_source: The package source of the archive. - :paramtype package_source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchivePackageSourceProperties - :keyword published_version: The published version of the archive. - :paramtype published_version: str - :keyword repository_endpoint_prefix: - :paramtype repository_endpoint_prefix: str - """ - super().__init__(**kwargs) - self.package_source = package_source - self.published_version = published_version - self.repository_endpoint_prefix = repository_endpoint_prefix - self.repository_endpoint = None - self.provisioning_state = None - - -class ArchiveUpdateParameters(_serialization.Model): - """The parameters for updating a archive. - - :ivar published_version: The published version of the archive. - :vartype published_version: str - """ - - _attribute_map = { - "published_version": {"key": "properties.publishedVersion", "type": "str"}, - } - - def __init__(self, *, published_version: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword published_version: The published version of the archive. - :paramtype published_version: str - """ - super().__init__(**kwargs) - self.published_version = published_version - - -class ArchiveVersion(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_06_06_preview.models.SystemData - :ivar provisioning_state: The provisioning state of the archive 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_06_06_preview.models.ProvisioningState - :ivar archive_version_error_message: The detailed error message for the archive version in the - case of failure. - :vartype archive_version_error_message: str - """ - - _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"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "archive_version_error_message": {"key": "properties.archiveVersionErrorMessage", "type": "str"}, - } - - def __init__(self, *, archive_version_error_message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword archive_version_error_message: The detailed error message for the archive version in - the case of failure. - :paramtype archive_version_error_message: str - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.archive_version_error_message = archive_version_error_message - - -class ArchiveVersionListResult(_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_06_06_preview.models.ArchiveVersion] - :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": "[ArchiveVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.ArchiveVersion"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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_06_06_preview.models.ArchiveVersion] - :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 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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword name: The name of the credential. "Credential1" - :paramtype name: str or ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.AzureADAuthenticationAsArmPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, *, status: Union[str, "_models.AzureADAuthenticationAsArmPolicyStatus"] = "enabled", **kwargs: Any - ) -> None: - """ - :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_06_06_preview.models.AzureADAuthenticationAsArmPolicyStatus - """ - super().__init__(**kwargs) - self.status = status - - -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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :keyword value: The list of cache rules. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_06_06_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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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): - """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_06_06_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_06_06_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_06_06_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_06_06_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_06_06_preview.models.ActivationProperties - :ivar parent: The parent of the connected registry. - :vartype parent: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.LoginServerProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.LoggingProperties - :ivar status_details: The list of current statuses of the connected registry. - :vartype status_details: - list[~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.ConnectedRegistryMode - :keyword parent: The parent of the connected registry. - :paramtype parent: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.LoginServerProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_preview.models.SyncUpdateProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :keyword sync_properties: The sync properties of the connected registry with its parent. - :paramtype sync_properties: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.SyncUpdateProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword status: The health status of credential. Known values are: "Healthy" and "Unhealthy". - :paramtype status: str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.SystemData - :ivar identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :vartype identity: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.AuthCredential] - """ - super().__init__(**kwargs) - self.identity = identity - self.auth_credentials = auth_credentials - - -class DebianArchivePackageSourceProperties(ArchivePackageSourceProperties): - """The properties of the archive package source. - - :ivar type: The type of package source for a archive. "remote" - :vartype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PackageSourceType - :ivar url: The external repository url. - :vartype url: str - :ivar distribution_name: Upstream Debian distribution Name. - :vartype distribution_name: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "distribution_name": {"key": "distributionName", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.PackageSourceType"]] = None, - url: Optional[str] = None, - distribution_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of package source for a archive. "remote" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PackageSourceType - :keyword url: The external repository url. - :paramtype url: str - :keyword distribution_name: Upstream Debian distribution Name. - :paramtype distribution_name: str - """ - super().__init__(type=type, url=url, **kwargs) - self.distribution_name = distribution_name - - -class DebianArchiveProperties(ArchiveProperties): - """The properties of the Debian package Archive. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar package_source: The package source of the archive. - :vartype package_source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchivePackageSourceProperties - :ivar published_version: The published version of the archive. - :vartype published_version: str - :ivar repository_endpoint_prefix: - :vartype repository_endpoint_prefix: str - :ivar repository_endpoint: - :vartype repository_endpoint: str - :ivar provisioning_state: The provisioning state of the archive 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_06_06_preview.models.ProvisioningState - :ivar distribution_name: Debian distribution Name. - :vartype distribution_name: str - """ - - _validation = { - "repository_endpoint": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "package_source": {"key": "packageSource", "type": "ArchivePackageSourceProperties"}, - "published_version": {"key": "publishedVersion", "type": "str"}, - "repository_endpoint_prefix": {"key": "repositoryEndpointPrefix", "type": "str"}, - "repository_endpoint": {"key": "repositoryEndpoint", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "distribution_name": {"key": "distributionName", "type": "str"}, - } - - def __init__( - self, - *, - package_source: Optional["_models.ArchivePackageSourceProperties"] = None, - published_version: Optional[str] = None, - repository_endpoint_prefix: Optional[str] = None, - distribution_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_source: The package source of the archive. - :paramtype package_source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchivePackageSourceProperties - :keyword published_version: The published version of the archive. - :paramtype published_version: str - :keyword repository_endpoint_prefix: - :paramtype repository_endpoint_prefix: str - :keyword distribution_name: Debian distribution Name. - :paramtype distribution_name: str - """ - super().__init__( - package_source=package_source, - published_version=published_version, - repository_endpoint_prefix=repository_endpoint_prefix, - **kwargs - ) - self.distribution_name = distribution_name - - -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_06_06_preview.models.EncryptionStatus - :ivar key_vault_properties: Key vault properties. - :vartype key_vault_properties: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.EncryptionStatus - :keyword key_vault_properties: Key vault properties. - :paramtype key_vault_properties: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.ErrorResponseBody - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorResponseBody"}, - } - - def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs: Any) -> None: - """ - :keyword error: Azure container registry build API error body. - :paramtype error: ~azure.mgmt.containerregistry.v2023_06_06_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 server. - - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any) -> None: # 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_06_06_preview.models.EventRequestMessage - :ivar event_response_message: The event response message received from the service URI. - :vartype event_response_message: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.EventRequestMessage - :keyword event_response_message: The event response message received from the service URI. - :paramtype event_response_message: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_preview.models.IdentityProperties - :ivar target: The target properties of the export pipeline. - :vartype target: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipelineTargetProperties - :ivar options: The list of all options configured for the pipeline. - :vartype options: list[str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.IdentityProperties - :keyword target: The target properties of the export pipeline. - :paramtype target: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipelineTargetProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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 server. - - :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: Any - ) -> None: - """ - :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_06_06_preview.models.ExportPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs: Any) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.TokenPassword] - """ - super().__init__(**kwargs) - self.username = username - self.passwords = passwords - - -class IdentityProperties(_serialization.Model): - """Managed identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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_06_06_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_06_06_preview.models.UserIdentityProperties] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _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, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.UserIdentityProperties] - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - 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 server. - - :ivar source: The source of the image. Required. - :vartype source: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword source: The source of the image. Required. - :paramtype source: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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_06_06_preview.models.IdentityProperties - :ivar source: The source properties of the import pipeline. - :vartype source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipelineSourceProperties - :ivar trigger: The properties that describe the trigger of the import pipeline. - :vartype trigger: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineTriggerProperties - :ivar options: The list of all options configured for the pipeline. - :vartype options: list[str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.IdentityProperties - :keyword source: The source properties of the import pipeline. - :paramtype source: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipelineSourceProperties - :keyword trigger: The properties that describe the trigger of the import pipeline. - :paramtype trigger: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineTriggerProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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 server. - - :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" - :vartype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_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 server. - - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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 server. - - :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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 server. - - :ivar action: The action of IP ACL rule. "Allow" - :vartype action: str or ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :keyword action: The action of IP ACL rule. "Allow" - :paramtype action: str or ~azure.mgmt.containerregistry.v2023_06_06_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: Any) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_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: Any) -> None: - """ """ - 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 server. - - :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_06_06_preview.models.DefaultAction - :ivar ip_rules: The IP ACL rules. - :vartype ip_rules: list[~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.DefaultAction - :keyword ip_rules: The IP ACL rules. - :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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. # pylint: disable=line-too-long - :paramtype is_data_action: bool - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_06_06_preview.models.OperationMetricSpecificationDefinition] - :ivar log_specifications: A list of Azure Monitoring log definitions. - :vartype log_specifications: - list[~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2023_06_06_preview.models.OperationMetricSpecificationDefinition] - :keyword log_specifications: A list of Azure Monitoring log definitions. - :paramtype log_specifications: - list[~azure.mgmt.containerregistry.v2023_06_06_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: Any) -> None: - """ - :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 server. - - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_preview.models.ProvisioningState - :ivar request: The request parameters for a pipeline run. - :vartype request: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineRunRequest - :ivar response: The response of a pipeline run. - :vartype response: ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :keyword request: The request parameters for a pipeline run. - :paramtype request: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_preview.models.PipelineRunSourceProperties - :ivar target: The target properties of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.PipelineRunSourceProperties - :keyword target: The target properties of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_preview.models.ImportPipelineSourceProperties - :ivar target: The target of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_preview.models.ImportPipelineSourceProperties - :keyword target: The target of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword type: The type of the source. "AzureStorageBlob" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword type: The type of the target. "AzureStorageBlob" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_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: Any) -> None: - """ - :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 server. - - :ivar status: The current status of the source trigger. Known values are: "Enabled" and - "Disabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2023_06_06_preview.models.TriggerStatus - """ - - _validation = { - "status": {"required": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.TriggerStatus"] = "Enabled", **kwargs: Any) -> None: - """ - :keyword status: The current status of the source trigger. Known values are: "Enabled" and - "Disabled". - :paramtype status: str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.PipelineSourceTriggerDescriptor - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger that caused the pipeline run. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.PipelineSourceTriggerProperties - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger properties of the pipeline. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.QuarantinePolicy - :ivar trust_policy: The content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.TrustPolicy - :ivar retention_policy: The retention policy for a container registry. - :vartype retention_policy: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RetentionPolicy - :ivar export_policy: The export policy for a container registry. - :vartype export_policy: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.AzureADAuthenticationAsArmPolicy - :ivar soft_delete_policy: The soft delete policy for a container registry. - :vartype soft_delete_policy: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :keyword quarantine_policy: The quarantine policy for a container registry. - :paramtype quarantine_policy: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.QuarantinePolicy - :keyword trust_policy: The content trust policy for a container registry. - :paramtype trust_policy: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.TrustPolicy - :keyword retention_policy: The retention policy for a container registry. - :paramtype retention_policy: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RetentionPolicy - :keyword export_policy: The export policy for a container registry. - :paramtype export_policy: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.AzureADAuthenticationAsArmPolicy - :keyword soft_delete_policy: The soft delete policy for a container registry. - :paramtype soft_delete_policy: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any) -> None: # 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_06_06_preview.models.SystemData - :ivar private_endpoint: The resource of private endpoint. - :vartype private_endpoint: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private endpoint. - :paramtype private_endpoint: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword status: The private link service connection status. Known values are: "Approved", - "Pending", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any) -> None: - """ - :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_06_06_preview.models.PolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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_06_06_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 server. - - :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_06_06_preview.models.PasswordName - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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_06_06_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 server. - - :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_06_06_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: Any) -> None: - """ - :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): - """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 server. - - :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_06_06_preview.models.SystemData - :ivar sku: The SKU of the container registry. Required. - :vartype sku: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Sku - :ivar identity: The identity of the container registry. - :vartype identity: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.ProvisioningState - :ivar status: The status of the container registry at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.Sku - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :keyword name: The password name. Known values are: "password" and "password2". - :paramtype name: str or ~azure.mgmt.containerregistry.v2023_06_06_preview.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.v2023_06_06_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_06_06_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_06_06_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_preview.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_06_06_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 server. - - :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_06_06_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_06_06_preview.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any - ) -> None: - """ - :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 server. - - :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_06_06_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_06_06_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: Any) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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: Any) -> None: - """ """ - 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 server. - - :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: Any) -> None: # 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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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: Any) -> None: - """ """ - 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_06_06_preview.models.TlsStatus - :ivar certificate: The certificate used to configure HTTPS for the login server. - :vartype certificate: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any) -> None: - """ """ - 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_06_06_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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword name: Known values are: "certificate1" and "certificate2". - :paramtype name: str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.TokenCertificate] - :ivar passwords: - :vartype passwords: - list[~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :keyword certificates: - :paramtype certificates: - list[~azure.mgmt.containerregistry.v2023_06_06_preview.models.TokenCertificate] - :keyword passwords: - :paramtype passwords: - list[~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_preview.models.TokenStatus - :ivar credentials: The credentials that can be used for authenticating the token. - :vartype credentials: - ~azure.mgmt.containerregistry.v2023_06_06_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: Any - ) -> None: - """ - :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_06_06_preview.models.TokenStatus - :keyword credentials: The credentials that can be used for authenticating the token. - :paramtype credentials: - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :keyword type: The type of trust policy. "Notary" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_06_06_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_06_06_preview.models.PolicyStatus - """ - super().__init__(**kwargs) - self.type = type - self.status = status - - -class UserIdentityProperties(_serialization.Model): - """UserIdentityProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -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 server. - - :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_06_06_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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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 server. - - :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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_06_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: Any - ) -> None: - """ - :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_06_06_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_06_06_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_06_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_06_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/__init__.py deleted file mode 100644 index 07d4637faf87..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._archives_operations import ArchivesOperations # type: ignore -from ._archive_versions_operations import ArchiveVersionsOperations # type: ignore -from ._cache_rules_operations import CacheRulesOperations # type: ignore -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._credential_sets_operations import CredentialSetsOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ArchivesOperations", - "ArchiveVersionsOperations", - "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__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_archive_versions_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_archive_versions_operations.py deleted file mode 100644 index 0e887da15110..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_archive_versions_operations.py +++ /dev/null @@ -1,731 +0,0 @@ -# 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, Iterator, Optional, TypeVar, Union, cast -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_name: str, - archive_version_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions/{archiveVersionName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - "archiveVersionName": _SERIALIZER.url( - "archive_version_name", - archive_version_name, - "str", - max_length=200, - min_length=5, - pattern=r"^[a-zA-Z0-9-]*$", - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_name: str, - archive_version_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions/{archiveVersionName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - "archiveVersionName": _SERIALIZER.url( - "archive_version_name", - archive_version_name, - "str", - max_length=200, - min_length=5, - pattern=r"^[a-zA-Z0-9-]*$", - ), - } - - _url: str = _url.format(**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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions/{archiveVersionName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - "archiveVersionName": _SERIALIZER.url( - "archive_version_name", - archive_version_name, - "str", - max_length=200, - min_length=5, - pattern=r"^[a-zA-Z0-9-]*$", - ), - } - - _url: str = _url.format(**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 ArchiveVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_06_06_preview.ContainerRegistryManagementClient`'s - :attr:`archive_versions` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> Iterable["_models.ArchiveVersion"]: - """Lists all archive versions for the specified container registry, repository type and archive - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: An iterator like instance of either ArchiveVersion or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveVersionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveVersionListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> _models.ArchiveVersion: - """Gets the properties of the archive version. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: ArchiveVersion or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("ArchiveVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> LROPoller[_models.ArchiveVersion]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: An instance of LROPoller that returns either ArchiveVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ArchiveVersion", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ArchiveVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ArchiveVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a archive version 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_archives_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_archives_operations.py deleted file mode 100644 index 156a404c6cd8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_archives_operations.py +++ /dev/null @@ -1,958 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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, package_type: 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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 ArchivesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_06_06_preview.ContainerRegistryManagementClient`'s - :attr:`archives` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, **kwargs: Any - ) -> Iterable["_models.Archive"]: - """Lists all archives for the specified container registry and package type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :return: An iterator like instance of either Archive or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ArchiveListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace - def get( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> _models.Archive: - """Gets the properties of the archive. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_create_parameters, (IOBase, bytes)): - _content = archive_create_parameters - else: - _json = self._serialize.body(archive_create_parameters, "Archive") - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: _models.Archive, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Archive or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Archive or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Is either a Archive - type or a IO[bytes] type. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive or IO[bytes] - :return: An instance of LROPoller that returns either Archive or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - package_type=package_type, - archive_name=archive_name, - archive_create_parameters=archive_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Archive", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Archive].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Archive]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: _models.ArchiveUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: Union[_models.ArchiveUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Is either a - ArchiveUpdateParameters type or a IO[bytes] type. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ArchiveUpdateParameters or IO[bytes] - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_update_parameters, (IOBase, bytes)): - _content = archive_update_parameters - else: - _json = self._serialize.body(archive_update_parameters, "ArchiveUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_cache_rules_operations.py deleted file mode 100644 index af69d06bcf0a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_cache_rules_operations.py +++ /dev/null @@ -1,963 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CacheRule or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CacheRule or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_create_parameters: Union[_models.CacheRule, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - CacheRule type or a IO[bytes] type. Required. - :type cache_rule_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRule or IO[bytes] - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - CacheRuleUpdateParameters type or a IO[bytes] type. Required. - :type cache_rule_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CacheRuleUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_connected_registries_operations.py deleted file mode 100644 index d84270f4b710..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_connected_registries_operations.py +++ /dev/null @@ -1,1168 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistry or IO[bytes] - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_credential_sets_operations.py deleted file mode 100644 index 50dcc10430d2..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_credential_sets_operations.py +++ /dev/null @@ -1,974 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CredentialSet or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CredentialSet or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_create_parameters: Union[_models.CredentialSet, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 CredentialSet type or a IO[bytes] type. Required. - :type credential_set_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSet or IO[bytes] - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 CredentialSetUpdateParameters type or a IO[bytes] type. Required. - :type credential_set_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CredentialSetUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_export_pipelines_operations.py deleted file mode 100644 index 09c2d8d11af0..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,708 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ExportPipeline or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ExportPipeline or IO[bytes] - :return: An instance of LROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_import_pipelines_operations.py deleted file mode 100644 index 64c6de5d67c7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,708 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ImportPipeline or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportPipeline or IO[bytes] - :return: An instance of LROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_operations.py deleted file mode 100644 index 1800f5aeca85..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :return: An iterator like instance of either OperationDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_06_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_pipeline_runs_operations.py deleted file mode 100644 index 4b79f96f22c1..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,706 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either PipelineRun or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PipelineRun or IO[bytes] - :return: An instance of LROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 21ed5e563b33..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,720 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_06_06_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 - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_registries_operations.py deleted file mode 100644 index 6f7eff0ec14f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_registries_operations.py +++ /dev/null @@ -1,2194 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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( # pylint: disable=name-too-long - 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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_06_06_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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry or IO[bytes] - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def regenerate_credential( - self, - resource_group_name: str, - registry_name: str, - regenerate_credential_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_06_06_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 - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.GenerateCredentialsParameters or - IO[bytes] - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_replications_operations.py deleted file mode 100644 index dc31d646c412..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_replications_operations.py +++ /dev/null @@ -1,958 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Replication or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Replication or - IO[bytes] - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ReplicationUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_scope_maps_operations.py deleted file mode 100644 index 0d6a32b6b97c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_scope_maps_operations.py +++ /dev/null @@ -1,961 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_06_06_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 - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMap or IO[bytes] - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.ScopeMapUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_tokens_operations.py deleted file mode 100644 index a21b870b1df4..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_tokens_operations.py +++ /dev/null @@ -1,960 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Token or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_06_06_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 - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Token - or IO[bytes] - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.TokenUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_webhooks_operations.py deleted file mode 100644 index c96720ea1610..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/operations/_webhooks_operations.py +++ /dev/null @@ -1,1276 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_06_06_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Webhook or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.WebhookCreateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_06_06_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 - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2023_06_06_preview.models.WebhookUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_06_06_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either Event or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_06_06_preview.models.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_06_06_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-06-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_06_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/__init__.py deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_configuration.py deleted file mode 100644 index e1d016cf1b5a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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-07-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: - api_version: str = kwargs.pop("api_version", "2023-07-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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_07_01/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_container_registry_management_client.py deleted file mode 100644 index facebeb0d124..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_container_registry_management_client.py +++ /dev/null @@ -1,160 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - CacheRulesOperations, - CredentialSetsOperations, - Operations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - ScopeMapsOperations, - TokensOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar cache_rules: CacheRulesOperations operations - :vartype cache_rules: azure.mgmt.containerregistry.v2023_07_01.operations.CacheRulesOperations - :ivar credential_sets: CredentialSetsOperations operations - :vartype credential_sets: - azure.mgmt.containerregistry.v2023_07_01.operations.CredentialSetsOperations - :ivar registries: RegistriesOperations operations - :vartype registries: azure.mgmt.containerregistry.v2023_07_01.operations.RegistriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2023_07_01.operations.Operations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2023_07_01.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2023_07_01.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: azure.mgmt.containerregistry.v2023_07_01.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: azure.mgmt.containerregistry.v2023_07_01.operations.TokensOperations - :ivar webhooks: WebhooksOperations operations - :vartype webhooks: azure.mgmt.containerregistry.v2023_07_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 "2023-07-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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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, "2023-07-01" - ) - self.credential_sets = CredentialSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-07-01") - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize, "2023-07-01") - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2023-07-01") - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_metadata.json deleted file mode 100644 index e3f9fbfad678..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_metadata.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "chosen_version": "2023-07-01", - "total_api_version_list": ["2023-07-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "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, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "cache_rules": "CacheRulesOperations", - "credential_sets": "CredentialSetsOperations", - "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/v2023_07_01/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_07_01/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_version.py deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/__init__.py deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_configuration.py deleted file mode 100644 index 9b4cafea94bb..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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-07-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: - api_version: str = kwargs.pop("api_version", "2023-07-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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_07_01/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_container_registry_management_client.py deleted file mode 100644 index 3dd9da95a76f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_container_registry_management_client.py +++ /dev/null @@ -1,165 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - CacheRulesOperations, - CredentialSetsOperations, - Operations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - ScopeMapsOperations, - TokensOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar cache_rules: CacheRulesOperations operations - :vartype cache_rules: - azure.mgmt.containerregistry.v2023_07_01.aio.operations.CacheRulesOperations - :ivar credential_sets: CredentialSetsOperations operations - :vartype credential_sets: - azure.mgmt.containerregistry.v2023_07_01.aio.operations.CredentialSetsOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2023_07_01.aio.operations.RegistriesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2023_07_01.aio.operations.Operations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2023_07_01.aio.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2023_07_01.aio.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2023_07_01.aio.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: azure.mgmt.containerregistry.v2023_07_01.aio.operations.TokensOperations - :ivar webhooks: WebhooksOperations operations - :vartype webhooks: azure.mgmt.containerregistry.v2023_07_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 "2023-07-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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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, "2023-07-01" - ) - self.credential_sets = CredentialSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize, "2023-07-01") - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-07-01" - ) - self.tokens = TokensOperations(self._client, self._config, self._serialize, self._deserialize, "2023-07-01") - self.webhooks = WebhooksOperations(self._client, self._config, self._serialize, self._deserialize, "2023-07-01") - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_07_01/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/__init__.py deleted file mode 100644 index d033dbb35a54..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._cache_rules_operations import CacheRulesOperations # type: ignore -from ._credential_sets_operations import CredentialSetsOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CacheRulesOperations", - "CredentialSetsOperations", - "RegistriesOperations", - "Operations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "ScopeMapsOperations", - "TokensOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_cache_rules_operations.py deleted file mode 100644 index 7561689bb287..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_cache_rules_operations.py +++ /dev/null @@ -1,765 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_01.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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CacheRule or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.CacheRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CacheRule or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.CacheRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_create_parameters: Union[_models.CacheRule, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CacheRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 - CacheRule type or a IO[bytes] type. Required. - :type cache_rule_create_parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.CacheRule - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CacheRuleUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 - CacheRuleUpdateParameters type or a IO[bytes] type. Required. - :type cache_rule_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.CacheRuleUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_credential_sets_operations.py deleted file mode 100644 index e17bbe27b4e5..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_credential_sets_operations.py +++ /dev/null @@ -1,772 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_01.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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CredentialSet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CredentialSet or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_create_parameters: Union[_models.CredentialSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CredentialSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 CredentialSet type or a IO[bytes] type. Required. - :type credential_set_create_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CredentialSetUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 CredentialSetUpdateParameters type or a IO[bytes] type. Required. - :type credential_set_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSetUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_operations.py deleted file mode 100644 index a9bd19271643..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_operations.py +++ /dev/null @@ -1,130 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :return: An iterator like instance of either OperationDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_07_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index e1cd547cc137..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,551 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2023_07_01.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_registries_operations.py deleted file mode 100644 index 78ea9903d37a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1698 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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_07_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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_01.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2023_07_01.models.Registry or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.GenerateCredentialsParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_replications_operations.py deleted file mode 100644 index e649aaa810cc..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_replications_operations.py +++ /dev/null @@ -1,759 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Replication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2023_07_01.models.Replication or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.ReplicationUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_scope_maps_operations.py deleted file mode 100644 index cb966cabaaf9..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_scope_maps_operations.py +++ /dev/null @@ -1,765 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMap or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMapUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_tokens_operations.py deleted file mode 100644 index 888874efcd87..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_tokens_operations.py +++ /dev/null @@ -1,757 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._tokens_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Token or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.Token or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.TokenUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_webhooks_operations.py deleted file mode 100644 index 95d81af1e502..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,971 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Webhook or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.WebhookCreateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.WebhookUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either Event or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/__init__.py deleted file mode 100644 index 477bce34e09c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/__init__.py +++ /dev/null @@ -1,250 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ActiveDirectoryObject, - Actor, - AuthCredential, - CacheRule, - CacheRuleUpdateParameters, - CacheRulesListResult, - CallbackConfig, - CredentialHealth, - CredentialSet, - CredentialSetListResult, - CredentialSetUpdateParameters, - EncryptionProperty, - ErrorAdditionalInfo, - ErrorDetail, - ErrorResponse, - Event, - EventContent, - EventInfo, - EventListResult, - EventRequestMessage, - EventResponseMessage, - ExportPolicy, - GenerateCredentialsParameters, - GenerateCredentialsResult, - IPRule, - IdentityProperties, - ImportImageParameters, - ImportSource, - ImportSourceCredentials, - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - Action, - ActionsRequired, - ConnectionStatus, - CreatedByType, - CredentialHealthStatus, - CredentialName, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - NetworkRuleBypassOptions, - PasswordName, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActiveDirectoryObject", - "Actor", - "AuthCredential", - "CacheRule", - "CacheRuleUpdateParameters", - "CacheRulesListResult", - "CallbackConfig", - "CredentialHealth", - "CredentialSet", - "CredentialSetListResult", - "CredentialSetUpdateParameters", - "EncryptionProperty", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Event", - "EventContent", - "EventInfo", - "EventListResult", - "EventRequestMessage", - "EventResponseMessage", - "ExportPolicy", - "GenerateCredentialsParameters", - "GenerateCredentialsResult", - "IPRule", - "IdentityProperties", - "ImportImageParameters", - "ImportSource", - "ImportSourceCredentials", - "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", - "CredentialHealthStatus", - "CredentialName", - "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__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/_container_registry_management_client_enums.py deleted file mode 100644 index 4c8249db58fc..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,217 +0,0 @@ -# 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 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 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): - """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 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/v2023_07_01/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/_models_py3.py deleted file mode 100644 index 805c25b30713..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/_models_py3.py +++ /dev/null @@ -1,3842 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - 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: Any) -> None: - """ - :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: Any) -> None: - """ - :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_07_01.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_07_01.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: Any - ) -> None: - """ - :keyword name: The name of the credential. "Credential1" - :paramtype name: str or ~azure.mgmt.containerregistry.v2023_07_01.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 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_07_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: Any) -> None: - """ """ - 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_07_01.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_07_01.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: Any - ) -> None: - """ - :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_07_01.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: Any - ) -> None: - """ - :keyword value: The list of cache rules. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_07_01.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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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 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_07_01.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: Any - ) -> None: - """ - :keyword status: The health status of credential. Known values are: "Healthy" and "Unhealthy". - :paramtype status: str or - ~azure.mgmt.containerregistry.v2023_07_01.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_07_01.models.SystemData - :ivar identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :vartype identity: ~azure.mgmt.containerregistry.v2023_07_01.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_07_01.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_07_01.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: Any - ) -> None: - """ - :keyword identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :paramtype identity: ~azure.mgmt.containerregistry.v2023_07_01.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_07_01.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_07_01.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: Any - ) -> None: - """ - :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_07_01.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_07_01.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_07_01.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: Any - ) -> None: - """ - :keyword identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :paramtype identity: ~azure.mgmt.containerregistry.v2023_07_01.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_07_01.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_07_01.models.EncryptionStatus - :ivar key_vault_properties: Key vault properties. - :vartype key_vault_properties: - ~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :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_07_01.models.EncryptionStatus - :keyword key_vault_properties: Key vault properties. - :paramtype key_vault_properties: - ~azure.mgmt.containerregistry.v2023_07_01.models.KeyVaultProperties - """ - super().__init__(**kwargs) - self.status = status - self.key_vault_properties = key_vault_properties - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.containerregistry.v2023_07_01.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.containerregistry.v2023_07_01.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.containerregistry.v2023_07_01.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.containerregistry.v2023_07_01.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -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: Any) -> None: # 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_07_01.models.EventRequestMessage - :ivar event_response_message: The event response message received from the service URI. - :vartype event_response_message: - ~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :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_07_01.models.EventRequestMessage - :keyword event_response_message: The event response message received from the service URI. - :paramtype event_response_message: - ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_01.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_01.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :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.v2023_07_01.models.ExportPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs: Any) -> None: - """ - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_01.models.TokenPassword] - """ - super().__init__(**kwargs) - self.username = username - self.passwords = passwords - - -class IdentityProperties(_serialization.Model): - """Managed identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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_07_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.v2023_07_01.models.UserIdentityProperties] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _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, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_01.models.UserIdentityProperties] - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - 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 server. - - :ivar source: The source of the image. Required. - :vartype source: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :keyword source: The source of the image. Required. - :paramtype source: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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 server. - - :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_07_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: Any - ) -> None: - """ - :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_07_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 server. - - :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: Any) -> None: - """ - :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 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 server. - - :ivar action: The action of IP ACL rule. "Allow" - :vartype action: str or ~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :keyword action: The action of IP ACL rule. "Allow" - :paramtype action: str or ~azure.mgmt.containerregistry.v2023_07_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: Any) -> None: - """ - :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 server. - - :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_07_01.models.DefaultAction - :ivar ip_rules: The IP ACL rules. - :vartype ip_rules: list[~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :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_07_01.models.DefaultAction - :keyword ip_rules: The IP ACL rules. - :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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. # pylint: disable=line-too-long - :paramtype is_data_action: bool - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_07_01.models.OperationMetricSpecificationDefinition] - :ivar log_specifications: A list of Azure Monitoring log definitions. - :vartype log_specifications: - list[~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2023_07_01.models.OperationMetricSpecificationDefinition] - :keyword log_specifications: A list of Azure Monitoring log definitions. - :paramtype log_specifications: - list[~azure.mgmt.containerregistry.v2023_07_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: Any) -> None: - """ - :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.v2023_07_01.models.QuarantinePolicy - :ivar trust_policy: The content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2023_07_01.models.TrustPolicy - :ivar retention_policy: The retention policy for a container registry. - :vartype retention_policy: ~azure.mgmt.containerregistry.v2023_07_01.models.RetentionPolicy - :ivar export_policy: The export policy for a container registry. - :vartype export_policy: ~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :keyword quarantine_policy: The quarantine policy for a container registry. - :paramtype quarantine_policy: ~azure.mgmt.containerregistry.v2023_07_01.models.QuarantinePolicy - :keyword trust_policy: The content trust policy for a container registry. - :paramtype trust_policy: ~azure.mgmt.containerregistry.v2023_07_01.models.TrustPolicy - :keyword retention_policy: The retention policy for a container registry. - :paramtype retention_policy: ~azure.mgmt.containerregistry.v2023_07_01.models.RetentionPolicy - :keyword export_policy: The export policy for a container registry. - :paramtype export_policy: ~azure.mgmt.containerregistry.v2023_07_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: Any) -> None: # 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_07_01.models.SystemData - :ivar private_endpoint: The resource of private endpoint. - :vartype private_endpoint: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private endpoint. - :paramtype private_endpoint: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :keyword status: The private link service connection status. Known values are: "Approved", - "Pending", "Rejected", and "Disconnected". - :paramtype status: str or ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_01.models.PolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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_07_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 server. - - :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_07_01.models.PasswordName - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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_07_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 server. - - :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_07_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: Any) -> None: - """ - :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): - """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 server. - - :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_07_01.models.SystemData - :ivar sku: The SKU of the container registry. Required. - :vartype sku: ~azure.mgmt.containerregistry.v2023_07_01.models.Sku - :ivar identity: The identity of the container registry. - :vartype identity: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_01.models.ProvisioningState - :ivar status: The status of the container registry at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_01.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2023_07_01.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_01.models.Sku - :keyword identity: The identity of the container registry. - :paramtype identity: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_01.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2023_07_01.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :keyword name: The password name. Known values are: "password" and "password2". - :paramtype name: str or ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_01.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2023_07_01.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :keyword identity: The identity of the container registry. - :paramtype identity: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_01.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2023_07_01.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_01.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_07_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 server. - - :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_07_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.v2023_07_01.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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_07_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: Any - ) -> None: - """ - :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 server. - - :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_07_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.v2023_07_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: Any) -> None: - """ - :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_07_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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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 server. - - :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: Any) -> None: # 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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :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.v2023_07_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.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :keyword name: Known values are: "certificate1" and "certificate2". - :paramtype name: str or ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_01.models.TokenCertificate] - :ivar passwords: - :vartype passwords: list[~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :keyword certificates: - :paramtype certificates: - list[~azure.mgmt.containerregistry.v2023_07_01.models.TokenCertificate] - :keyword passwords: - :paramtype passwords: list[~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_01.models.TokenStatus - :ivar credentials: The credentials that can be used for authenticating the token. - :vartype credentials: - ~azure.mgmt.containerregistry.v2023_07_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: Any - ) -> None: - """ - :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_07_01.models.TokenStatus - :keyword credentials: The credentials that can be used for authenticating the token. - :paramtype credentials: - ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :keyword type: The type of trust policy. "Notary" - :paramtype type: str or ~azure.mgmt.containerregistry.v2023_07_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.v2023_07_01.models.PolicyStatus - """ - super().__init__(**kwargs) - self.type = type - self.status = status - - -class UserIdentityProperties(_serialization.Model): - """UserIdentityProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -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 server. - - :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_07_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.v2023_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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 server. - - :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_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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.v2023_07_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: Any - ) -> None: - """ - :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_07_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.v2023_07_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/v2023_07_01/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_07_01/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/__init__.py deleted file mode 100644 index d033dbb35a54..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._cache_rules_operations import CacheRulesOperations # type: ignore -from ._credential_sets_operations import CredentialSetsOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "CacheRulesOperations", - "CredentialSetsOperations", - "RegistriesOperations", - "Operations", - "PrivateEndpointConnectionsOperations", - "ReplicationsOperations", - "ScopeMapsOperations", - "TokensOperations", - "WebhooksOperations", -] -__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_cache_rules_operations.py deleted file mode 100644 index 13eee06ddaba..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_cache_rules_operations.py +++ /dev/null @@ -1,946 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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}/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 = _url.format(**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_07_01.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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CacheRule or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.CacheRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CacheRule or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.CacheRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_create_parameters: Union[_models.CacheRule, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CacheRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 - CacheRule type or a IO[bytes] type. Required. - :type cache_rule_create_parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.CacheRule - or IO[bytes] - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CacheRuleUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 - CacheRuleUpdateParameters type or a IO[bytes] type. Required. - :type cache_rule_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.CacheRuleUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_credential_sets_operations.py deleted file mode 100644 index 2424d43542a1..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_credential_sets_operations.py +++ /dev/null @@ -1,957 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-01")) - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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}/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 = _url.format(**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_07_01.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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CredentialSet or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CredentialSet or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_create_parameters: Union[_models.CredentialSet, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CredentialSet - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 CredentialSet type or a IO[bytes] type. Required. - :type credential_set_create_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSet or IO[bytes] - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_01.models.CredentialSetUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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[bytes]], - **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 CredentialSetUpdateParameters type or a IO[bytes] type. Required. - :type credential_set_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.CredentialSetUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_operations.py deleted file mode 100644 index 5eee5576f5bf..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_operations.py +++ /dev/null @@ -1,152 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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.v2023_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :return: An iterator like instance of either OperationDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_07_01/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index fffbaf59cca6..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,704 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2023_07_01.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_registries_operations.py deleted file mode 100644 index 2bc5fede30cb..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_registries_operations.py +++ /dev/null @@ -1,2148 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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( # pylint: disable=name-too-long - 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.ImportImageParameters or - IO[bytes] - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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_07_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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def check_name_availability( - self, registry_name_check_request: Union[_models.RegistryNameCheckRequest, IO[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2023_07_01.models.Registry or IO[bytes] - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_01.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_update( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def regenerate_credential( - self, - resource_group_name: str, - registry_name: str, - regenerate_credential_parameters: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.RegenerateCredentialParameters or IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.GenerateCredentialsParameters or IO[bytes] - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_replications_operations.py deleted file mode 100644 index 3a54e8779af0..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_replications_operations.py +++ /dev/null @@ -1,940 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Replication or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2023_07_01.models.Replication or IO[bytes] - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.ReplicationUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_scope_maps_operations.py deleted file mode 100644 index b79e59c24c43..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_scope_maps_operations.py +++ /dev/null @@ -1,943 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ScopeMap or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_07_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 - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMap or - IO[bytes] - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.ScopeMapUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_tokens_operations.py deleted file mode 100644 index f6fd80a5cf6f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_tokens_operations.py +++ /dev/null @@ -1,937 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Token or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_07_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 - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_07_01.models.Token or - IO[bytes] - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.TokenUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_webhooks_operations.py deleted file mode 100644 index d9e6dc537d3c..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/operations/_webhooks_operations.py +++ /dev/null @@ -1,1246 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-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 = _url.format(**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_07_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Webhook or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.WebhookCreateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_07_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 - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2023_07_01.models.WebhookUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_07_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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either Event or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_07_01.models.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-01")) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_07_01.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop("api_version", _params.pop("api-version", self._api_version or "2023-07-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_07_01/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/__init__.py deleted file mode 100644 index 8094e33eefa7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore -from ._version import VERSION - -__version__ = VERSION - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_configuration.py deleted file mode 100644 index 12715c10ec5f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy - -from ._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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-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: - api_version: str = kwargs.pop("api_version", "2023-08-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**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_08_01_preview/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_container_registry_management_client.py deleted file mode 100644 index 56d7a8c6dec0..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_container_registry_management_client.py +++ /dev/null @@ -1,212 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import HttpRequest, HttpResponse -from azure.mgmt.core import ARMPipelineClient -from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy - -from . import models as _models -from .._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - ArchiveVersionsOperations, - ArchivesOperations, - CacheRulesOperations, - ConnectedRegistriesOperations, - CredentialSetsOperations, - ExportPipelinesOperations, - ImportPipelinesOperations, - Operations, - PipelineRunsOperations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - ScopeMapsOperations, - TokensOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials import TokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar archives: ArchivesOperations operations - :vartype archives: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.ArchivesOperations - :ivar archive_versions: ArchiveVersionsOperations operations - :vartype archive_versions: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.ArchiveVersionsOperations - :ivar cache_rules: CacheRulesOperations operations - :vartype cache_rules: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.CacheRulesOperations - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.ConnectedRegistriesOperations - :ivar credential_sets: CredentialSetsOperations operations - :vartype credential_sets: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.CredentialSetsOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2023_08_01_preview.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2023_08_01_preview.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: azure.mgmt.containerregistry.v2023_08_01_preview.operations.TokensOperations - :ivar webhooks: WebhooksOperations operations - :vartype webhooks: - azure.mgmt.containerregistry.v2023_08_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-08-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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - ARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **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.archives = ArchivesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.archive_versions = ArchiveVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.cache_rules = CacheRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.credential_sets = CredentialSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - - def _send_request(self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - def close(self) -> None: - self._client.close() - - def __enter__(self) -> Self: - self._client.__enter__() - return self - - def __exit__(self, *exc_details: Any) -> None: - self._client.__exit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_metadata.json b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_metadata.json deleted file mode 100644 index 3bd676fc1870..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_metadata.json +++ /dev/null @@ -1,124 +0,0 @@ -{ - "chosen_version": "2023-08-01-preview", - "total_api_version_list": ["2023-08-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_public_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"sdkcore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"AsyncARMAutoResourceProviderRegistrationPolicy\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"ContainerRegistryManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}, \"stdlib\": {\"typing_extensions\": [\"Self\"]}}, \"typing\": {\"sdkcore\": {\"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, - "method_location": "positional" - }, - "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, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles=KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - }, - "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, - "method_location": "positional" - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false, - "method_location": "positional" - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false, - "method_location": "positional" - } - } - } - }, - "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\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"sdkcore\": {\"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"sdkcore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "archives": "ArchivesOperations", - "archive_versions": "ArchiveVersionsOperations", - "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_08_01_preview/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_08_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_version.py deleted file mode 100644 index ae876c37f272..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/_version.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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 = "11.0.0" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/__init__.py deleted file mode 100644 index 4eb80e51062e..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._container_registry_management_client import ContainerRegistryManagementClient # type: ignore - -try: - from ._patch import __all__ as _patch_all - from ._patch 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__]) # pyright: ignore - -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_configuration.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_configuration.py deleted file mode 100644 index 0770a19e607d..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_configuration.py +++ /dev/null @@ -1,64 +0,0 @@ -# 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 typing import Any, TYPE_CHECKING - -from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy - -from .._version import VERSION - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long - """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-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: - api_version: str = kwargs.pop("api_version", "2023-08-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.polling_interval = kwargs.get("polling_interval", 30) - 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.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**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_08_01_preview/aio/_container_registry_management_client.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_container_registry_management_client.py deleted file mode 100644 index 552665f770dc..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_container_registry_management_client.py +++ /dev/null @@ -1,215 +0,0 @@ -# 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 typing_extensions import Self - -from azure.core.pipeline import policies -from azure.core.rest import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient -from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy - -from .. import models as _models -from ..._serialization import Deserializer, Serializer -from ._configuration import ContainerRegistryManagementClientConfiguration -from .operations import ( - ArchiveVersionsOperations, - ArchivesOperations, - CacheRulesOperations, - ConnectedRegistriesOperations, - CredentialSetsOperations, - ExportPipelinesOperations, - ImportPipelinesOperations, - Operations, - PipelineRunsOperations, - PrivateEndpointConnectionsOperations, - RegistriesOperations, - ReplicationsOperations, - ScopeMapsOperations, - TokensOperations, - WebhooksOperations, -) - -if TYPE_CHECKING: - from azure.core.credentials_async import AsyncTokenCredential - - -class ContainerRegistryManagementClient: # pylint: disable=too-many-instance-attributes - """ContainerRegistryManagementClient. - - :ivar archives: ArchivesOperations operations - :vartype archives: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.ArchivesOperations - :ivar archive_versions: ArchiveVersionsOperations operations - :vartype archive_versions: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.ArchiveVersionsOperations - :ivar cache_rules: CacheRulesOperations operations - :vartype cache_rules: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.CacheRulesOperations - :ivar connected_registries: ConnectedRegistriesOperations operations - :vartype connected_registries: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.ConnectedRegistriesOperations - :ivar credential_sets: CredentialSetsOperations operations - :vartype credential_sets: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.CredentialSetsOperations - :ivar export_pipelines: ExportPipelinesOperations operations - :vartype export_pipelines: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.ExportPipelinesOperations - :ivar registries: RegistriesOperations operations - :vartype registries: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.RegistriesOperations - :ivar import_pipelines: ImportPipelinesOperations operations - :vartype import_pipelines: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.ImportPipelinesOperations - :ivar operations: Operations operations - :vartype operations: azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.Operations - :ivar pipeline_runs: PipelineRunsOperations operations - :vartype pipeline_runs: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.PipelineRunsOperations - :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.PrivateEndpointConnectionsOperations - :ivar replications: ReplicationsOperations operations - :vartype replications: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.ReplicationsOperations - :ivar scope_maps: ScopeMapsOperations operations - :vartype scope_maps: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.ScopeMapsOperations - :ivar tokens: TokensOperations operations - :vartype tokens: - azure.mgmt.containerregistry.v2023_08_01_preview.aio.operations.TokensOperations - :ivar webhooks: WebhooksOperations operations - :vartype webhooks: - azure.mgmt.containerregistry.v2023_08_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-08-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 - ) - _policies = kwargs.pop("policies", None) - if _policies is None: - _policies = [ - policies.RequestIdPolicy(**kwargs), - self._config.headers_policy, - self._config.user_agent_policy, - self._config.proxy_policy, - policies.ContentDecodePolicy(**kwargs), - AsyncARMAutoResourceProviderRegistrationPolicy(), - self._config.redirect_policy, - self._config.retry_policy, - self._config.authentication_policy, - self._config.custom_hook_policy, - self._config.logging_policy, - policies.DistributedTracingPolicy(**kwargs), - policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, - self._config.http_logging_policy, - ] - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **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.archives = ArchivesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.archive_versions = ArchiveVersionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.cache_rules = CacheRulesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.connected_registries = ConnectedRegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.credential_sets = CredentialSetsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.export_pipelines = ExportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.registries = RegistriesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.import_pipelines = ImportPipelinesOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.pipeline_runs = PipelineRunsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.private_endpoint_connections = PrivateEndpointConnectionsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.replications = ReplicationsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.scope_maps = ScopeMapsOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.tokens = TokensOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - self.webhooks = WebhooksOperations( - self._client, self._config, self._serialize, self._deserialize, "2023-08-01-preview" - ) - - def _send_request( - self, request: HttpRequest, *, stream: bool = False, **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, stream=stream, **kwargs) # type: ignore - - async def close(self) -> None: - await self._client.close() - - async def __aenter__(self) -> Self: - await self._client.__aenter__() - return self - - async def __aexit__(self, *exc_details: Any) -> None: - await self._client.__aexit__(*exc_details) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_08_01_preview/aio/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/__init__.py deleted file mode 100644 index 07d4637faf87..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._archives_operations import ArchivesOperations # type: ignore -from ._archive_versions_operations import ArchiveVersionsOperations # type: ignore -from ._cache_rules_operations import CacheRulesOperations # type: ignore -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._credential_sets_operations import CredentialSetsOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ArchivesOperations", - "ArchiveVersionsOperations", - "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__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_archive_versions_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_archive_versions_operations.py deleted file mode 100644 index 40093c355a18..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_archive_versions_operations.py +++ /dev/null @@ -1,525 +0,0 @@ -# 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, AsyncIterator, Callable, Dict, Optional, TypeVar, Union, cast -import urllib.parse - -from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._archive_versions_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ArchiveVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_08_01_preview.aio.ContainerRegistryManagementClient`'s - :attr:`archive_versions` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ArchiveVersion"]: - # pylint: disable=line-too-long - """Lists all archive versions for the specified container registry, repository type and archive - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: An iterator like instance of either ArchiveVersion or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveVersionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveVersionListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace_async - async def get( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> _models.ArchiveVersion: - """Gets the properties of the archive version. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: ArchiveVersion or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("ArchiveVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[_models.ArchiveVersion]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: An instance of AsyncLROPoller that returns either ArchiveVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ArchiveVersion", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ArchiveVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ArchiveVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a archive version 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_archives_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_archives_operations.py deleted file mode 100644 index 339d5009e52a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_archives_operations.py +++ /dev/null @@ -1,738 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._archives_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -T = TypeVar("T") -ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] - - -class ArchivesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_08_01_preview.aio.ContainerRegistryManagementClient`'s - :attr:`archives` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, **kwargs: Any - ) -> AsyncIterable["_models.Archive"]: - """Lists all archives for the specified container registry and package type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :return: An iterator like instance of either Archive or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace_async - async def get( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> _models.Archive: - """Gets the properties of the archive. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_create_parameters, (IOBase, bytes)): - _content = archive_create_parameters - else: - _json = self._serialize.body(archive_create_parameters, "Archive") - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: _models.Archive, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Archive or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Archive or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Is either a Archive - type or a IO[bytes] type. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Archive or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("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, - package_type=package_type, - archive_name=archive_name, - archive_create_parameters=archive_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Archive", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Archive].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Archive]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def begin_delete( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - async def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: _models.ArchiveUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: Union[_models.ArchiveUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Is either a - ArchiveUpdateParameters type or a IO[bytes] type. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveUpdateParameters or IO[bytes] - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_update_parameters, (IOBase, bytes)): - _content = archive_update_parameters - else: - _json = self._serialize.body(archive_update_parameters, "ArchiveUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_cache_rules_operations.py deleted file mode 100644 index 4f6bd0ba5fc0..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_cache_rules_operations.py +++ /dev/null @@ -1,782 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CacheRule or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CacheRule or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_create_parameters: Union[_models.CacheRule, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - CacheRule type or a IO[bytes] type. Required. - :type cache_rule_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRule or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - CacheRuleUpdateParameters type or a IO[bytes] type. Required. - :type cache_rule_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRuleUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CacheRule or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_connected_registries_operations.py deleted file mode 100644 index 9d29f8163fe0..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_connected_registries_operations.py +++ /dev/null @@ -1,917 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable["_models.ConnectedRegistry"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_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 - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistry or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_credential_sets_operations.py deleted file mode 100644 index 9b8e80c79e1a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_credential_sets_operations.py +++ /dev/null @@ -1,789 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CredentialSet or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CredentialSet or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_create_parameters: Union[_models.CredentialSet, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 CredentialSet type or a IO[bytes] type. Required. - :type credential_set_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSet or IO[bytes] - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 CredentialSetUpdateParameters type or a IO[bytes] type. Required. - :type credential_set_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSetUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_export_pipelines_operations.py deleted file mode 100644 index b774a382d36b..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._export_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ExportPipeline"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either ExportPipeline or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipeline or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_import_pipelines_operations.py deleted file mode 100644 index 26d3fccc0215..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,563 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._import_pipelines_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ImportPipeline"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either ImportPipeline or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipeline or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_operations.py deleted file mode 100644 index 74c0cf375244..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_operations.py +++ /dev/null @@ -1,133 +0,0 @@ -# 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.rest import AsyncHttpResponse, 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 ...operations._operations import build_list_request - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDefinition"]: - # pylint: disable=line-too-long - """Lists all of the available Azure Container Registry REST API operations. - - :return: An iterator like instance of either OperationDefinition or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_08_01_preview/aio/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_pipeline_runs_operations.py deleted file mode 100644 index fb2c5c29a952..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,558 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._pipeline_runs_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either PipelineRun or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineRun or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 6cbe5139ed50..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,566 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_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 - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_registries_operations.py deleted file mode 100644 index 367e3af68c46..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_registries_operations.py +++ /dev/null @@ -1,1743 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - async def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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_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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> AsyncIterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Registry or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list_private_link_resources( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResource"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_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 - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncLROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.GenerateCredentialsParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either GenerateCredentialsResult or the - result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_replications_operations.py deleted file mode 100644 index 5bff614d3e2a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_replications_operations.py +++ /dev/null @@ -1,777 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._replications_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Replication or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Replication or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :return: An instance of AsyncLROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_scope_maps_operations.py deleted file mode 100644 index 17f5869a80ae..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_scope_maps_operations.py +++ /dev/null @@ -1,782 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMap or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMapUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either ScopeMap or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_tokens_operations.py deleted file mode 100644 index 2738ed6af8d8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_tokens_operations.py +++ /dev/null @@ -1,773 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...operations._tokens_operations import ( - build_create_request, - build_delete_request, - build_get_request, - build_list_request, - build_update_request, -) - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Token or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Token - or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.TokenUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_webhooks_operations.py deleted file mode 100644 index 24b6376df254..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/aio/operations/_webhooks_operations.py +++ /dev/null @@ -1,993 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, AsyncIterable, AsyncIterator, 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, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.pipeline import PipelineResponse -from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod -from azure.core.rest import AsyncHttpResponse, 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 ...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, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Webhook or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.WebhookCreateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - async def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[AsyncIterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - async def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.WebhookUpdateParameters or IO[bytes] - :return: An instance of AsyncLROPoller that returns either Webhook or the result of - cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either Event or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/__init__.py deleted file mode 100644 index c66a366804a1..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/__init__.py +++ /dev/null @@ -1,358 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - - -from ._models_py3 import ( # type: ignore - ActivationProperties, - ActiveDirectoryObject, - Actor, - Archive, - ArchiveListResult, - ArchivePackageSourceProperties, - ArchiveProperties, - ArchiveUpdateParameters, - ArchiveVersion, - ArchiveVersionListResult, - AuthCredential, - AzureADAuthenticationAsArmPolicy, - CacheRule, - CacheRuleUpdateParameters, - CacheRulesListResult, - CallbackConfig, - ConnectedRegistry, - ConnectedRegistryListResult, - ConnectedRegistryUpdateParameters, - CredentialHealth, - CredentialSet, - CredentialSetListResult, - CredentialSetUpdateParameters, - DebianArchivePackageSourceProperties, - DebianArchiveProperties, - EncryptionProperty, - ErrorAdditionalInfo, - ErrorDetail, - ErrorResponse, - Event, - EventContent, - EventInfo, - EventListResult, - EventRequestMessage, - EventResponseMessage, - ExportPipeline, - ExportPipelineListResult, - ExportPipelineTargetProperties, - ExportPolicy, - GenerateCredentialsParameters, - GenerateCredentialsResult, - IPRule, - IdentityProperties, - ImportImageParameters, - ImportPipeline, - ImportPipelineListResult, - ImportPipelineSourceProperties, - ImportSource, - ImportSourceCredentials, - 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, -) - -from ._container_registry_management_client_enums import ( # type: ignore - Action, - ActionsRequired, - ActivationStatus, - AuditLogStatus, - AzureADAuthenticationAsArmPolicyStatus, - CertificateType, - ConnectedRegistryMode, - ConnectionState, - ConnectionStatus, - CreatedByType, - CredentialHealthStatus, - CredentialName, - DefaultAction, - EncryptionStatus, - ExportPolicyStatus, - ImportMode, - LastModifiedByType, - LogLevel, - NetworkRuleBypassOptions, - PackageSourceType, - PasswordName, - PipelineOptions, - PipelineRunSourceType, - PipelineRunTargetType, - PipelineSourceType, - PolicyStatus, - ProvisioningState, - PublicNetworkAccess, - RegistryUsageUnit, - ResourceIdentityType, - SkuName, - SkuTier, - TlsStatus, - TokenCertificateName, - TokenPasswordName, - TokenStatus, - TriggerStatus, - TrustPolicyType, - WebhookAction, - WebhookStatus, - ZoneRedundancy, -) -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ActivationProperties", - "ActiveDirectoryObject", - "Actor", - "Archive", - "ArchiveListResult", - "ArchivePackageSourceProperties", - "ArchiveProperties", - "ArchiveUpdateParameters", - "ArchiveVersion", - "ArchiveVersionListResult", - "AuthCredential", - "AzureADAuthenticationAsArmPolicy", - "CacheRule", - "CacheRuleUpdateParameters", - "CacheRulesListResult", - "CallbackConfig", - "ConnectedRegistry", - "ConnectedRegistryListResult", - "ConnectedRegistryUpdateParameters", - "CredentialHealth", - "CredentialSet", - "CredentialSetListResult", - "CredentialSetUpdateParameters", - "DebianArchivePackageSourceProperties", - "DebianArchiveProperties", - "EncryptionProperty", - "ErrorAdditionalInfo", - "ErrorDetail", - "ErrorResponse", - "Event", - "EventContent", - "EventInfo", - "EventListResult", - "EventRequestMessage", - "EventResponseMessage", - "ExportPipeline", - "ExportPipelineListResult", - "ExportPipelineTargetProperties", - "ExportPolicy", - "GenerateCredentialsParameters", - "GenerateCredentialsResult", - "IPRule", - "IdentityProperties", - "ImportImageParameters", - "ImportPipeline", - "ImportPipelineListResult", - "ImportPipelineSourceProperties", - "ImportSource", - "ImportSourceCredentials", - "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", - "PackageSourceType", - "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__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/_container_registry_management_client_enums.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/_container_registry_management_client_enums.py deleted file mode 100644 index 1ac71a8a0af3..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/_container_registry_management_client_enums.py +++ /dev/null @@ -1,319 +0,0 @@ -# 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 PackageSourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of package source for a archive.""" - - REMOTE = "remote" - - -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): - """The provisioning state of the archive at the time the operation was called.""" - - 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_08_01_preview/models/_models_py3.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/_models_py3.py deleted file mode 100644 index c4a2730e0060..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/_models_py3.py +++ /dev/null @@ -1,5753 +0,0 @@ -# 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 datetime -from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union - -from ... import _serialization - -if TYPE_CHECKING: - 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_08_01_preview.models.ActivationStatus - """ - - _validation = { - "status": {"readonly": True}, - } - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - 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: Any) -> None: - """ - :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: Any) -> None: - """ - :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 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_08_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: Any) -> None: - """ """ - super().__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class Archive(ProxyResource): - """An object that represents a archive 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_08_01_preview.models.SystemData - :ivar package_source: The package source of the archive. - :vartype package_source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchivePackageSourceProperties - :ivar published_version: The published version of the archive. - :vartype published_version: str - :ivar repository_endpoint_prefix: - :vartype repository_endpoint_prefix: str - :ivar repository_endpoint: - :vartype repository_endpoint: str - :ivar provisioning_state: The provisioning state of the archive 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_08_01_preview.models.ProvisioningState - """ - - _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "system_data": {"readonly": True}, - "repository_endpoint": {"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"}, - "package_source": {"key": "properties.packageSource", "type": "ArchivePackageSourceProperties"}, - "published_version": {"key": "properties.publishedVersion", "type": "str"}, - "repository_endpoint_prefix": {"key": "properties.repositoryEndpointPrefix", "type": "str"}, - "repository_endpoint": {"key": "properties.repositoryEndpoint", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - package_source: Optional["_models.ArchivePackageSourceProperties"] = None, - published_version: Optional[str] = None, - repository_endpoint_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_source: The package source of the archive. - :paramtype package_source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchivePackageSourceProperties - :keyword published_version: The published version of the archive. - :paramtype published_version: str - :keyword repository_endpoint_prefix: - :paramtype repository_endpoint_prefix: str - """ - super().__init__(**kwargs) - self.package_source = package_source - self.published_version = published_version - self.repository_endpoint_prefix = repository_endpoint_prefix - self.repository_endpoint = None - self.provisioning_state = None - - -class ArchiveListResult(_serialization.Model): - """The result of a request to list archives for a container registry. - - :ivar value: The list of archives. Since this list may be incomplete, the nextLink field should - be used to request the next list of distributions. - :vartype value: list[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :ivar next_link: The URI that can be used to request the next list of archives. - :vartype next_link: str - """ - - _attribute_map = { - "value": {"key": "value", "type": "[Archive]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.Archive"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword value: The list of archives. Since this list may be incomplete, the nextLink field - should be used to request the next list of distributions. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :keyword next_link: The URI that can be used to request the next list of archives. - :paramtype next_link: str - """ - super().__init__(**kwargs) - self.value = value - self.next_link = next_link - - -class ArchivePackageSourceProperties(_serialization.Model): - """The properties of the archive package source. - - :ivar type: The type of package source for a archive. "remote" - :vartype type: str or - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PackageSourceType - :ivar url: The external repository url. - :vartype url: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "url": {"key": "url", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.PackageSourceType"]] = None, - url: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of package source for a archive. "remote" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PackageSourceType - :keyword url: The external repository url. - :paramtype url: str - """ - super().__init__(**kwargs) - self.type = type - self.url = url - - -class ArchiveProperties(_serialization.Model): - """The properties of a archive. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar package_source: The package source of the archive. - :vartype package_source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchivePackageSourceProperties - :ivar published_version: The published version of the archive. - :vartype published_version: str - :ivar repository_endpoint_prefix: - :vartype repository_endpoint_prefix: str - :ivar repository_endpoint: - :vartype repository_endpoint: str - :ivar provisioning_state: The provisioning state of the archive 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_08_01_preview.models.ProvisioningState - """ - - _validation = { - "repository_endpoint": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "package_source": {"key": "packageSource", "type": "ArchivePackageSourceProperties"}, - "published_version": {"key": "publishedVersion", "type": "str"}, - "repository_endpoint_prefix": {"key": "repositoryEndpointPrefix", "type": "str"}, - "repository_endpoint": {"key": "repositoryEndpoint", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - } - - def __init__( - self, - *, - package_source: Optional["_models.ArchivePackageSourceProperties"] = None, - published_version: Optional[str] = None, - repository_endpoint_prefix: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_source: The package source of the archive. - :paramtype package_source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchivePackageSourceProperties - :keyword published_version: The published version of the archive. - :paramtype published_version: str - :keyword repository_endpoint_prefix: - :paramtype repository_endpoint_prefix: str - """ - super().__init__(**kwargs) - self.package_source = package_source - self.published_version = published_version - self.repository_endpoint_prefix = repository_endpoint_prefix - self.repository_endpoint = None - self.provisioning_state = None - - -class ArchiveUpdateParameters(_serialization.Model): - """The parameters for updating a archive. - - :ivar published_version: The published version of the archive. - :vartype published_version: str - """ - - _attribute_map = { - "published_version": {"key": "properties.publishedVersion", "type": "str"}, - } - - def __init__(self, *, published_version: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword published_version: The published version of the archive. - :paramtype published_version: str - """ - super().__init__(**kwargs) - self.published_version = published_version - - -class ArchiveVersion(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_08_01_preview.models.SystemData - :ivar provisioning_state: The provisioning state of the archive 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_08_01_preview.models.ProvisioningState - :ivar archive_version_error_message: The detailed error message for the archive version in the - case of failure. - :vartype archive_version_error_message: str - """ - - _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"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "archive_version_error_message": {"key": "properties.archiveVersionErrorMessage", "type": "str"}, - } - - def __init__(self, *, archive_version_error_message: Optional[str] = None, **kwargs: Any) -> None: - """ - :keyword archive_version_error_message: The detailed error message for the archive version in - the case of failure. - :paramtype archive_version_error_message: str - """ - super().__init__(**kwargs) - self.provisioning_state = None - self.archive_version_error_message = archive_version_error_message - - -class ArchiveVersionListResult(_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_08_01_preview.models.ArchiveVersion] - :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": "[ArchiveVersion]"}, - "next_link": {"key": "nextLink", "type": "str"}, - } - - def __init__( - self, *, value: Optional[List["_models.ArchiveVersion"]] = None, next_link: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :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_08_01_preview.models.ArchiveVersion] - :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 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_08_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_08_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: Any - ) -> None: - """ - :keyword name: The name of the credential. "Credential1" - :paramtype name: str or ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.AzureADAuthenticationAsArmPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__( - self, *, status: Union[str, "_models.AzureADAuthenticationAsArmPolicyStatus"] = "enabled", **kwargs: Any - ) -> None: - """ - :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_08_01_preview.models.AzureADAuthenticationAsArmPolicyStatus - """ - super().__init__(**kwargs) - self.status = status - - -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_08_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_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :keyword value: The list of cache rules. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: - """ - :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 server. - - :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: Any) -> None: - """ - :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): - """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_08_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_08_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_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. Known values - are: "Online", "Offline", "Syncing", and "Unhealthy". - :vartype connection_state: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.ActivationProperties - :ivar parent: The parent of the connected registry. - :vartype parent: ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.LoginServerProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.LoggingProperties - :ivar status_details: The list of current statuses of the connected registry. - :vartype status_details: - list[~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.ConnectedRegistryMode - :keyword parent: The parent of the connected registry. - :paramtype parent: ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.LoginServerProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_01_preview.models.SyncUpdateProperties - :ivar logging: The logging properties of the connected registry. - :vartype logging: ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :keyword sync_properties: The sync properties of the connected registry with its parent. - :paramtype sync_properties: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.SyncUpdateProperties - :keyword logging: The logging properties of the connected registry. - :paramtype logging: ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :keyword status: The health status of credential. Known values are: "Healthy" and "Unhealthy". - :paramtype status: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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_08_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_08_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: Any - ) -> None: - """ - :keyword identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_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_08_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: Any - ) -> None: - """ - :keyword identity: Identities associated with the resource. This is used to access the KeyVault - secrets. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.AuthCredential] - """ - super().__init__(**kwargs) - self.identity = identity - self.auth_credentials = auth_credentials - - -class DebianArchivePackageSourceProperties(ArchivePackageSourceProperties): - """The properties of the archive package source. - - :ivar type: The type of package source for a archive. "remote" - :vartype type: str or - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PackageSourceType - :ivar url: The external repository url. - :vartype url: str - :ivar distribution_name: Upstream Debian distribution Name. - :vartype distribution_name: str - """ - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "url": {"key": "url", "type": "str"}, - "distribution_name": {"key": "distributionName", "type": "str"}, - } - - def __init__( - self, - *, - type: Optional[Union[str, "_models.PackageSourceType"]] = None, - url: Optional[str] = None, - distribution_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The type of package source for a archive. "remote" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PackageSourceType - :keyword url: The external repository url. - :paramtype url: str - :keyword distribution_name: Upstream Debian distribution Name. - :paramtype distribution_name: str - """ - super().__init__(type=type, url=url, **kwargs) - self.distribution_name = distribution_name - - -class DebianArchiveProperties(ArchiveProperties): - """The properties of the Debian package Archive. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar package_source: The package source of the archive. - :vartype package_source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchivePackageSourceProperties - :ivar published_version: The published version of the archive. - :vartype published_version: str - :ivar repository_endpoint_prefix: - :vartype repository_endpoint_prefix: str - :ivar repository_endpoint: - :vartype repository_endpoint: str - :ivar provisioning_state: The provisioning state of the archive 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_08_01_preview.models.ProvisioningState - :ivar distribution_name: Debian distribution Name. - :vartype distribution_name: str - """ - - _validation = { - "repository_endpoint": {"readonly": True}, - "provisioning_state": {"readonly": True}, - } - - _attribute_map = { - "package_source": {"key": "packageSource", "type": "ArchivePackageSourceProperties"}, - "published_version": {"key": "publishedVersion", "type": "str"}, - "repository_endpoint_prefix": {"key": "repositoryEndpointPrefix", "type": "str"}, - "repository_endpoint": {"key": "repositoryEndpoint", "type": "str"}, - "provisioning_state": {"key": "provisioningState", "type": "str"}, - "distribution_name": {"key": "distributionName", "type": "str"}, - } - - def __init__( - self, - *, - package_source: Optional["_models.ArchivePackageSourceProperties"] = None, - published_version: Optional[str] = None, - repository_endpoint_prefix: Optional[str] = None, - distribution_name: Optional[str] = None, - **kwargs: Any - ) -> None: - """ - :keyword package_source: The package source of the archive. - :paramtype package_source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchivePackageSourceProperties - :keyword published_version: The published version of the archive. - :paramtype published_version: str - :keyword repository_endpoint_prefix: - :paramtype repository_endpoint_prefix: str - :keyword distribution_name: Debian distribution Name. - :paramtype distribution_name: str - """ - super().__init__( - package_source=package_source, - published_version=published_version, - repository_endpoint_prefix=repository_endpoint_prefix, - **kwargs - ) - self.distribution_name = distribution_name - - -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_08_01_preview.models.EncryptionStatus - :ivar key_vault_properties: Key vault properties. - :vartype key_vault_properties: - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.EncryptionStatus - :keyword key_vault_properties: Key vault properties. - :paramtype key_vault_properties: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.KeyVaultProperties - """ - super().__init__(**kwargs) - self.status = status - self.key_vault_properties = key_vault_properties - - -class ErrorAdditionalInfo(_serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: JSON - """ - - _validation = { - "type": {"readonly": True}, - "info": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "info": {"key": "info", "type": "object"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(_serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: - list[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ErrorAdditionalInfo] - """ - - _validation = { - "code": {"readonly": True}, - "message": {"readonly": True}, - "target": {"readonly": True}, - "details": {"readonly": True}, - "additional_info": {"readonly": True}, - } - - _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, - "target": {"key": "target", "type": "str"}, - "details": {"key": "details", "type": "[ErrorDetail]"}, - "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(_serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed - operations. (This also follows the OData error response format.). - - :ivar error: The error object. - :vartype error: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ErrorDetail - """ - - _attribute_map = { - "error": {"key": "error", "type": "ErrorDetail"}, - } - - def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: - """ - :keyword error: The error object. - :paramtype error: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ErrorDetail - """ - super().__init__(**kwargs) - self.error = error - - -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: Any) -> None: # 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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_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_08_01_preview.models.Target - :ivar request: The request that generated the event. - :vartype request: ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.Target - :keyword request: The request that generated the event. - :paramtype request: ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :keyword content: The content of the event request message. - :paramtype content: ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_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_08_01_preview.models.IdentityProperties - :ivar target: The target properties of the export pipeline. - :vartype target: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipelineTargetProperties - :ivar options: The list of all options configured for the pipeline. - :vartype options: list[str or - ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.IdentityProperties - :keyword target: The target properties of the export pipeline. - :paramtype target: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipelineTargetProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_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 server. - - :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: Any - ) -> None: - """ - :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_08_01_preview.models.ExportPolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Union[str, "_models.ExportPolicyStatus"] = "enabled", **kwargs: Any) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.TokenPassword] - """ - super().__init__(**kwargs) - self.username = username - self.passwords = passwords - - -class IdentityProperties(_serialization.Model): - """Managed identity for the resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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_08_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_08_01_preview.models.UserIdentityProperties] - """ - - _validation = { - "principal_id": {"readonly": True}, - "tenant_id": {"readonly": True}, - } - - _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, - *, - type: Optional[Union[str, "_models.ResourceIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "_models.UserIdentityProperties"]] = None, - **kwargs: Any - ) -> None: - """ - :keyword type: The identity type. Known values are: "SystemAssigned", "UserAssigned", - "SystemAssigned, UserAssigned", and "None". - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.UserIdentityProperties] - """ - super().__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - 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 server. - - :ivar source: The source of the image. Required. - :vartype source: ~azure.mgmt.containerregistry.v2023_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). - :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_08_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: Any - ) -> None: - """ - :keyword source: The source of the image. Required. - :paramtype source: ~azure.mgmt.containerregistry.v2023_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). - :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_08_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_08_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_08_01_preview.models.IdentityProperties - :ivar source: The source properties of the import pipeline. - :vartype source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipelineSourceProperties - :ivar trigger: The properties that describe the trigger of the import pipeline. - :vartype trigger: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineTriggerProperties - :ivar options: The list of all options configured for the pipeline. - :vartype options: list[str or - ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.IdentityProperties - :keyword source: The source properties of the import pipeline. - :paramtype source: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipelineSourceProperties - :keyword trigger: The properties that describe the trigger of the import pipeline. - :paramtype trigger: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineTriggerProperties - :keyword options: The list of all options configured for the pipeline. - :paramtype options: list[str or - ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_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 server. - - :ivar type: The type of source for the import pipeline. "AzureStorageBlobContainer" - :vartype type: str or - ~azure.mgmt.containerregistry.v2023_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: 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: Any - ) -> None: - """ - :keyword type: The type of source for the import pipeline. "AzureStorageBlobContainer" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_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: 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 server. - - :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_08_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: Any - ) -> None: - """ - :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_08_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 server. - - :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: Any) -> None: - """ - :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 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 server. - - :ivar action: The action of IP ACL rule. "Allow" - :vartype action: str or ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :keyword action: The action of IP ACL rule. "Allow" - :paramtype action: str or ~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_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_08_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: Any) -> None: - """ """ - 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 server. - - :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_08_01_preview.models.DefaultAction - :ivar ip_rules: The IP ACL rules. - :vartype ip_rules: list[~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.DefaultAction - :keyword ip_rules: The IP ACL rules. - :paramtype ip_rules: list[~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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. # pylint: disable=line-too-long - :paramtype is_data_action: bool - :keyword service_specification: The definition of Azure Monitoring service. - :paramtype service_specification: - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_08_01_preview.models.OperationMetricSpecificationDefinition] - :ivar log_specifications: A list of Azure Monitoring log definitions. - :vartype log_specifications: - list[~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :keyword metric_specifications: A list of Azure Monitoring metrics definition. - :paramtype metric_specifications: - list[~azure.mgmt.containerregistry.v2023_08_01_preview.models.OperationMetricSpecificationDefinition] - :keyword log_specifications: A list of Azure Monitoring log definitions. - :paramtype log_specifications: - list[~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: - """ - :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 server. - - :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_08_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: Any - ) -> None: - """ - :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_08_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_08_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_08_01_preview.models.ProvisioningState - :ivar request: The request parameters for a pipeline run. - :vartype request: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineRunRequest - :ivar response: The response of a pipeline run. - :vartype response: ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :keyword request: The request parameters for a pipeline run. - :paramtype request: ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_01_preview.models.PipelineRunSourceProperties - :ivar target: The target properties of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.PipelineRunSourceProperties - :keyword target: The target properties of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_01_preview.models.ImportPipelineSourceProperties - :ivar target: The target of the pipeline run. - :vartype target: - ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_01_preview.models.ImportPipelineSourceProperties - :keyword target: The target of the pipeline run. - :paramtype target: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :keyword type: The type of the source. "AzureStorageBlob" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :keyword type: The type of the target. "AzureStorageBlob" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: - """ - :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 server. - - :ivar status: The current status of the source trigger. Known values are: "Enabled" and - "Disabled". - :vartype status: str or ~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: - """ - :keyword status: The current status of the source trigger. Known values are: "Enabled" and - "Disabled". - :paramtype status: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.PipelineSourceTriggerDescriptor - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerDescriptor"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerDescriptor"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger that caused the pipeline run. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.PipelineSourceTriggerProperties - """ - - _attribute_map = { - "source_trigger": {"key": "sourceTrigger", "type": "PipelineSourceTriggerProperties"}, - } - - def __init__( - self, *, source_trigger: Optional["_models.PipelineSourceTriggerProperties"] = None, **kwargs: Any - ) -> None: - """ - :keyword source_trigger: The source trigger properties of the pipeline. - :paramtype source_trigger: - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.QuarantinePolicy - :ivar trust_policy: The content trust policy for a container registry. - :vartype trust_policy: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.TrustPolicy - :ivar retention_policy: The retention policy for a container registry. - :vartype retention_policy: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RetentionPolicy - :ivar export_policy: The export policy for a container registry. - :vartype export_policy: ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.AzureADAuthenticationAsArmPolicy - :ivar soft_delete_policy: The soft delete policy for a container registry. - :vartype soft_delete_policy: - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :keyword quarantine_policy: The quarantine policy for a container registry. - :paramtype quarantine_policy: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.QuarantinePolicy - :keyword trust_policy: The content trust policy for a container registry. - :paramtype trust_policy: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.TrustPolicy - :keyword retention_policy: The retention policy for a container registry. - :paramtype retention_policy: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RetentionPolicy - :keyword export_policy: The export policy for a container registry. - :paramtype export_policy: ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.AzureADAuthenticationAsArmPolicy - :keyword soft_delete_policy: The soft delete policy for a container registry. - :paramtype soft_delete_policy: - ~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: # 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_08_01_preview.models.SystemData - :ivar private_endpoint: The resource of private endpoint. - :vartype private_endpoint: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :keyword private_endpoint: The resource of private endpoint. - :paramtype private_endpoint: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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_08_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_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. Known values are: "None" and "Recreate". - :vartype actions_required: str or - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :keyword status: The private link service connection status. Known values are: "Approved", - "Pending", "Rejected", and "Disconnected". - :paramtype status: str or - ~azure.mgmt.containerregistry.v2023_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. Known values are: "None" and "Recreate". - :paramtype actions_required: str or - ~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: - """ - :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_08_01_preview.models.PolicyStatus - """ - - _attribute_map = { - "status": {"key": "status", "type": "str"}, - } - - def __init__(self, *, status: Optional[Union[str, "_models.PolicyStatus"]] = None, **kwargs: Any) -> None: - """ - :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_08_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 server. - - :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_08_01_preview.models.PasswordName - """ - - _validation = { - "name": {"required": True}, - } - - _attribute_map = { - "name": {"key": "name", "type": "str"}, - } - - def __init__(self, *, name: Union[str, "_models.PasswordName"], **kwargs: Any) -> None: - """ - :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_08_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 server. - - :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_08_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: Any) -> None: - """ - :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): - """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 server. - - :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_08_01_preview.models.SystemData - :ivar sku: The SKU of the container registry. Required. - :vartype sku: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Sku - :ivar identity: The identity of the container registry. - :vartype identity: ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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_08_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.Sku - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :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_08_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 server. - - :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: Any) -> None: - """ - :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: Any - ) -> None: - """ - :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_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"}, - } - - def __init__( - self, *, name: Optional[Union[str, "_models.PasswordName"]] = None, value: Optional[str] = None, **kwargs: Any - ) -> None: - """ - :keyword name: The password name. Known values are: "password" and "password2". - :paramtype name: str or ~azure.mgmt.containerregistry.v2023_08_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): - """The parameters for updating a container registry. - - :ivar identity: The identity of the container registry. - :vartype identity: ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_01_preview.models.NetworkRuleSet - :ivar policies: The policies for a container registry. - :vartype policies: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Policies - :ivar encryption: The encryption settings of container registry. - :vartype encryption: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :keyword identity: The identity of the container registry. - :paramtype identity: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_01_preview.models.NetworkRuleSet - :keyword policies: The policies for a container registry. - :paramtype policies: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Policies - :keyword encryption: The encryption settings of container registry. - :paramtype encryption: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_01_preview.models.RegistryUsage] - """ - - _attribute_map = { - "value": {"key": "value", "type": "[RegistryUsage]"}, - } - - def __init__(self, *, value: Optional[List["_models.RegistryUsage"]] = None, **kwargs: Any) -> None: - """ - :keyword value: The list of container registry quota usages. - :paramtype value: list[~azure.mgmt.containerregistry.v2023_08_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 server. - - :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_08_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_08_01_preview.models.ProvisioningState - :ivar status: The status of the replication at the time the operation was called. - :vartype status: ~azure.mgmt.containerregistry.v2023_08_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_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}, - } - - _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: Any - ) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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_08_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: Any - ) -> None: - """ - :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 server. - - :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_08_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_08_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: Any) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :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_08_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: Any) -> None: - """ - :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: Any) -> None: - """ """ - 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: Any) -> None: - """ """ - 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 server. - - :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: Any) -> None: # 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 server. - - :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: Any - ) -> None: - """ - :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: Any - ) -> None: - """ - :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_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. Known values - are: "User", "Application", "ManagedIdentity", and "Key". - :vartype last_modified_by_type: str or - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_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. Known - values are: "User", "Application", "ManagedIdentity", and "Key". - :paramtype last_modified_by_type: str or - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_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: Any) -> None: - """ """ - 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_08_01_preview.models.TlsStatus - :ivar certificate: The certificate used to configure HTTPS for the login server. - :vartype certificate: - ~azure.mgmt.containerregistry.v2023_08_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: Any) -> None: - """ """ - 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_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. Known values are: "Creating", - "Updating", "Deleting", "Succeeded", "Failed", and "Canceled". - :vartype provisioning_state: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_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_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}, - } - - _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: Any - ) -> None: - """ - :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_08_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_08_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_08_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: Any - ) -> None: - """ - :keyword name: Known values are: "certificate1" and "certificate2". - :paramtype name: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.TokenCertificate] - :ivar passwords: - :vartype passwords: - list[~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :keyword certificates: - :paramtype certificates: - list[~azure.mgmt.containerregistry.v2023_08_01_preview.models.TokenCertificate] - :keyword passwords: - :paramtype passwords: - list[~azure.mgmt.containerregistry.v2023_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_08_01_preview.models.TokenStatus - :ivar credentials: The credentials that can be used for authenticating the token. - :vartype credentials: - ~azure.mgmt.containerregistry.v2023_08_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: Any - ) -> None: - """ - :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_08_01_preview.models.TokenStatus - :keyword credentials: The credentials that can be used for authenticating the token. - :paramtype credentials: - ~azure.mgmt.containerregistry.v2023_08_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_08_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_08_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: Any - ) -> None: - """ - :keyword type: The type of trust policy. "Notary" - :paramtype type: str or - ~azure.mgmt.containerregistry.v2023_08_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_08_01_preview.models.PolicyStatus - """ - super().__init__(**kwargs) - self.type = type - self.status = status - - -class UserIdentityProperties(_serialization.Model): - """UserIdentityProperties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :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 - """ - - _validation = { - "principal_id": {"readonly": True}, - "client_id": {"readonly": True}, - } - - _attribute_map = { - "principal_id": {"key": "principalId", "type": "str"}, - "client_id": {"key": "clientId", "type": "str"}, - } - - def __init__(self, **kwargs: Any) -> None: - """ """ - super().__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -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 server. - - :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_08_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_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. - '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_08_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_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}, - } - - _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: Any - ) -> None: - """ - :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_08_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_08_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 server. - - :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_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. - '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_08_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: Any - ) -> None: - """ - :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_08_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_08_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_08_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: Any - ) -> None: - """ - :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_08_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_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. - '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_08_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: Any - ) -> None: - """ - :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_08_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_08_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_08_01_preview/models/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/models/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_08_01_preview/operations/__init__.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/__init__.py deleted file mode 100644 index 07d4637faf87..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/__init__.py +++ /dev/null @@ -1,53 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -# pylint: disable=wrong-import-position - -from typing import TYPE_CHECKING - -if TYPE_CHECKING: - from ._patch import * # pylint: disable=unused-wildcard-import - -from ._archives_operations import ArchivesOperations # type: ignore -from ._archive_versions_operations import ArchiveVersionsOperations # type: ignore -from ._cache_rules_operations import CacheRulesOperations # type: ignore -from ._connected_registries_operations import ConnectedRegistriesOperations # type: ignore -from ._credential_sets_operations import CredentialSetsOperations # type: ignore -from ._export_pipelines_operations import ExportPipelinesOperations # type: ignore -from ._registries_operations import RegistriesOperations # type: ignore -from ._import_pipelines_operations import ImportPipelinesOperations # type: ignore -from ._operations import Operations # type: ignore -from ._pipeline_runs_operations import PipelineRunsOperations # type: ignore -from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations # type: ignore -from ._replications_operations import ReplicationsOperations # type: ignore -from ._scope_maps_operations import ScopeMapsOperations # type: ignore -from ._tokens_operations import TokensOperations # type: ignore -from ._webhooks_operations import WebhooksOperations # type: ignore - -from ._patch import __all__ as _patch_all -from ._patch import * -from ._patch import patch_sdk as _patch_sdk - -__all__ = [ - "ArchivesOperations", - "ArchiveVersionsOperations", - "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__]) # pyright: ignore -_patch_sdk() diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_archive_versions_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_archive_versions_operations.py deleted file mode 100644 index 96095baeef4f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_archive_versions_operations.py +++ /dev/null @@ -1,731 +0,0 @@ -# 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, Iterator, Optional, TypeVar, Union, cast -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_name: str, - archive_version_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions/{archiveVersionName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - "archiveVersionName": _SERIALIZER.url( - "archive_version_name", - archive_version_name, - "str", - max_length=200, - min_length=5, - pattern=r"^[a-zA-Z0-9-]*$", - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_name: str, - archive_version_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions/{archiveVersionName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - "archiveVersionName": _SERIALIZER.url( - "archive_version_name", - archive_version_name, - "str", - max_length=200, - min_length=5, - pattern=r"^[a-zA-Z0-9-]*$", - ), - } - - _url: str = _url.format(**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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_delete_request( - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}/versions/{archiveVersionName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - "archiveVersionName": _SERIALIZER.url( - "archive_version_name", - archive_version_name, - "str", - max_length=200, - min_length=5, - pattern=r"^[a-zA-Z0-9-]*$", - ), - } - - _url: str = _url.format(**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 ArchiveVersionsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_08_01_preview.ContainerRegistryManagementClient`'s - :attr:`archive_versions` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> Iterable["_models.ArchiveVersion"]: - """Lists all archive versions for the specified container registry, repository type and archive - name. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: An iterator like instance of either ArchiveVersion or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveVersionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveVersionListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace - def get( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> _models.ArchiveVersion: - """Gets the properties of the archive version. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: ArchiveVersion or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("ArchiveVersion", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> LROPoller[_models.ArchiveVersion]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :return: An instance of LROPoller that returns either ArchiveVersion or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveVersion] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ArchiveVersion", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ArchiveVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ArchiveVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_version_name: str, - **kwargs: Any - ) -> LROPoller[None]: - """Deletes a archive version 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_version_name: The name of the archive version resource. Required. - :type archive_version_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - archive_version_name=archive_version_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_archives_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_archives_operations.py deleted file mode 100644 index 99e2b9556643..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_archives_operations.py +++ /dev/null @@ -1,958 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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, package_type: 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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, - package_type: str, - archive_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/packages/{packageType}/archives/{archiveName}", - ) # pylint: disable=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]*$" - ), - "packageType": _SERIALIZER.url( - "package_type", package_type, "str", max_length=50, min_length=3, pattern=r"^[a-zA-Z]*$" - ), - "archiveName": _SERIALIZER.url( - "archive_name", archive_name, "str", max_length=200, min_length=5, pattern=r"^[a-zA-Z0-9-]*$" - ), - } - - _url: str = _url.format(**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 ArchivesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.mgmt.containerregistry.v2023_08_01_preview.ContainerRegistryManagementClient`'s - :attr:`archives` 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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, package_type: str, **kwargs: Any - ) -> Iterable["_models.Archive"]: - """Lists all archives for the specified container registry and package type. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :return: An iterator like instance of either Archive or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ArchiveListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - package_type=package_type, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _request.url = self._client.format_url(_request.url) - _request.method = "GET" - return _request - - def extract_data(pipeline_response): - deserialized = self._deserialize("ArchiveListResult", 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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @distributed_trace - def get( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> _models.Archive: - """Gets the properties of the archive. - - :param resource_group_name: The name of the resource group. The name is case insensitive. - Required. - :type resource_group_name: str - :param registry_name: The name of the container registry. Required. - :type registry_name: str - :param package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - _request = build_get_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_create_parameters, (IOBase, bytes)): - _content = archive_create_parameters - else: - _json = self._serialize.body(archive_create_parameters, "Archive") - - _request = build_create_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: _models.Archive, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Archive or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Required. - :type archive_create_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Archive or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def begin_create( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_create_parameters: Union[_models.Archive, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.Archive]: - """Creates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_create_parameters: The parameters for creating a archive. Is either a Archive - type or a IO[bytes] type. Required. - :type archive_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive or IO[bytes] - :return: An instance of LROPoller that returns either Archive or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.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, - package_type=package_type, - archive_name=archive_name, - archive_create_parameters=archive_create_parameters, - api_version=api_version, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Archive", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Archive].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Archive]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - _request = build_delete_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def begin_delete( - self, resource_group_name: str, registry_name: str, package_type: str, archive_name: str, **kwargs: Any - ) -> LROPoller[None]: - """Deletes a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @overload - def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: _models.ArchiveUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Required. - :type archive_update_parameters: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def update( - self, - resource_group_name: str, - registry_name: str, - package_type: str, - archive_name: str, - archive_update_parameters: Union[_models.ArchiveUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> _models.Archive: - """Updates a archive 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 package_type: The type of the package resource. Required. - :type package_type: str - :param archive_name: The name of the archive resource. Required. - :type archive_name: str - :param archive_update_parameters: The parameters for updating a archive. Is either a - ArchiveUpdateParameters type or a IO[bytes] type. Required. - :type archive_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ArchiveUpdateParameters or IO[bytes] - :return: Archive or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Archive - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Archive] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(archive_update_parameters, (IOBase, bytes)): - _content = archive_update_parameters - else: - _json = self._serialize.body(archive_update_parameters, "ArchiveUpdateParameters") - - _request = build_update_request( - resource_group_name=resource_group_name, - registry_name=registry_name, - package_type=package_type, - archive_name=archive_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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("Archive", pipeline_response.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_cache_rules_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_cache_rules_operations.py deleted file mode 100644 index ecff74475866..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_cache_rules_operations.py +++ /dev/null @@ -1,963 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CacheRule or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.CacheRulesListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CacheRule or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRule - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_create_parameters: Union[_models.CacheRule, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - CacheRule type or a IO[bytes] type. Required. - :type cache_rule_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRule or IO[bytes] - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, cache_rule_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - cache_rule_name: str, - cache_rule_update_parameters: Union[_models.CacheRuleUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(cache_rule_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - CacheRuleUpdateParameters type or a IO[bytes] type. Required. - :type cache_rule_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CacheRuleUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either CacheRule or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CacheRule", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CacheRule].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CacheRule]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_connected_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_connected_registries_operations.py deleted file mode 100644 index 975bce5c1061..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_connected_registries_operations.py +++ /dev/null @@ -1,1168 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ConnectedRegistry or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ConnectedRegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ConnectedRegistry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_create_parameters: Union[_models.ConnectedRegistry, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 ConnectedRegistry type or a IO[bytes] type. Required. - :type connected_registry_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistry or IO[bytes] - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - connected_registry_name: str, - connected_registry_update_parameters: Union[_models.ConnectedRegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(connected_registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 ConnectedRegistryUpdateParameters type or a IO[bytes] type. Required. - :type connected_registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ConnectedRegistryUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either ConnectedRegistry or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ConnectedRegistry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ConnectedRegistry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ConnectedRegistry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _deactivate_initial( - self, resource_group_name: str, registry_name: str, connected_registry_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_credential_sets_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_credential_sets_operations.py deleted file mode 100644 index 283590fad1ce..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_credential_sets_operations.py +++ /dev/null @@ -1,974 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either CredentialSet or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSet] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.CredentialSetListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: CredentialSet or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSet - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_create_parameters: Union[_models.CredentialSet, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 CredentialSet type or a IO[bytes] type. Required. - :type credential_set_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSet or IO[bytes] - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, credential_set_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - credential_set_name: str, - credential_set_update_parameters: Union[_models.CredentialSetUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(credential_set_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_08_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 - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 CredentialSetUpdateParameters type or a IO[bytes] type. Required. - :type credential_set_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CredentialSetUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either CredentialSet or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("CredentialSet", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.CredentialSet].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.CredentialSet]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_export_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_export_pipelines_operations.py deleted file mode 100644 index b72e4fd9e5a1..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_export_pipelines_operations.py +++ /dev/null @@ -1,708 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ExportPipeline or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ExportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ExportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - export_pipeline_name: str, - export_pipeline_create_parameters: Union[_models.ExportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(export_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 ExportPipeline type or a IO[bytes] type. Required. - :type export_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ExportPipeline or IO[bytes] - :return: An instance of LROPoller that returns either ExportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ExportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ExportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ExportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, export_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_import_pipelines_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_import_pipelines_operations.py deleted file mode 100644 index 0ff873380fe7..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_import_pipelines_operations.py +++ /dev/null @@ -1,708 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ImportPipeline or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipeline] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ImportPipelineListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ImportPipeline or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipeline - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - import_pipeline_name: str, - import_pipeline_create_parameters: Union[_models.ImportPipeline, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(import_pipeline_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 ImportPipeline type or a IO[bytes] type. Required. - :type import_pipeline_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportPipeline or IO[bytes] - :return: An instance of LROPoller that returns either ImportPipeline or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ImportPipeline", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ImportPipeline].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ImportPipeline]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, import_pipeline_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_operations.py deleted file mode 100644 index 5f9edb470148..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_operations.py +++ /dev/null @@ -1,154 +0,0 @@ -# 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.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.OperationDefinition"]: - """Lists all of the available Azure Container Registry REST API operations. - - :return: An iterator like instance of either OperationDefinition or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.OperationDefinition] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_patch.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_patch.py deleted file mode 100644 index f7dd32510333..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_patch.py +++ /dev/null @@ -1,20 +0,0 @@ -# ------------------------------------ -# 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_08_01_preview/operations/_pipeline_runs_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_pipeline_runs_operations.py deleted file mode 100644 index f44dd62c7f89..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_pipeline_runs_operations.py +++ /dev/null @@ -1,706 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either PipelineRun or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineRun] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.PipelineRunListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: PipelineRun or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineRun - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - pipeline_run_name: str, - pipeline_run_create_parameters: Union[_models.PipelineRun, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(pipeline_run_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - PipelineRun type or a IO[bytes] type. Required. - :type pipeline_run_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PipelineRun or IO[bytes] - :return: An instance of LROPoller that returns either PipelineRun or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PipelineRun", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PipelineRun].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PipelineRun]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, pipeline_run_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_private_endpoint_connections_operations.py deleted file mode 100644 index 756d748eb74f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_private_endpoint_connections_operations.py +++ /dev/null @@ -1,720 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @distributed_trace - def list( - self, resource_group_name: str, registry_name: str, **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnection"]: - # pylint: disable=line-too-long - """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 - :return: An iterator like instance of either PrivateEndpointConnection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.PrivateEndpointConnectionListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateEndpointConnection - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - 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[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(private_endpoint_connection, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_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 - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **kwargs: Any - ) -> LROPoller[_models.PrivateEndpointConnection]: - # pylint: disable=line-too-long - """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 PrivateEndpointConnection type or a IO[bytes] type. Required. - :type private_endpoint_connection: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateEndpointConnection or IO[bytes] - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.PrivateEndpointConnection].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.PrivateEndpointConnection]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, private_endpoint_connection_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_registries_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_registries_operations.py deleted file mode 100644 index be720902afad..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_registries_operations.py +++ /dev/null @@ -1,2194 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), - } - - _url: str = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-08-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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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( # pylint: disable=name-too-long - 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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - def _import_image_initial( - self, - resource_group_name: str, - registry_name: str, - parameters: Union[_models.ImportImageParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :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[bytes]], - **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 ImportImageParameters type or a IO[bytes] type. Required. - :type parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ImportImageParameters or IO[bytes] - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - @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_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 - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def check_name_availability( - self, registry_name_check_request: IO[bytes], *, 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_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[bytes]], **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 RegistryNameCheckRequest type or a IO[bytes] type. Required. - :type registry_name_check_request: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryNameCheckRequest or IO[bytes] - :return: RegistryNameStatus or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryNameStatus - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list(self, **kwargs: Any) -> Iterable["_models.Registry"]: - """Lists all the container registries under the specified subscription. - - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: An iterator like instance of either Registry or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.RegistryListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Registry or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, resource_group_name: str, registry_name: str, registry: Union[_models.Registry, IO[bytes]], **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create( - self, - resource_group_name: str, - registry_name: str, - registry: IO[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes]], **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 Registry type or - a IO[bytes] type. Required. - :type registry: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Registry or IO[bytes] - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial(self, resource_group_name: str, registry_name: str, **kwargs: Any) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - registry_update_parameters: Union[_models.RegistryUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(registry_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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: Union[_models.RegistryUpdateParameters, IO[bytes]], - **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 RegistryUpdateParameters type or a IO[bytes] type. Required. - :type registry_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Registry or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Registry", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Registry].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Registry]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: RegistryUsageListResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryUsageListResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateLinkResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: PrivateLinkResource or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.PrivateLinkResource - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_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: Union[_models.RegenerateCredentialParameters, IO[bytes]], - **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 RegenerateCredentialParameters type or a - IO[bytes] type. Required. - :type regenerate_credential_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegenerateCredentialParameters or - IO[bytes] - :return: RegistryListCredentialsResult or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.RegistryListCredentialsResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-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, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _generate_credentials_initial( - self, - resource_group_name: str, - registry_name: str, - generate_credentials_parameters: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(generate_credentials_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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]: - # pylint: disable=line-too-long - """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_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 - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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: Union[_models.GenerateCredentialsParameters, IO[bytes]], - **kwargs: Any - ) -> LROPoller[_models.GenerateCredentialsResult]: - # pylint: disable=line-too-long - """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 - GenerateCredentialsParameters type or a IO[bytes] type. Required. - :type generate_credentials_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.GenerateCredentialsParameters or - IO[bytes] - :return: An instance of LROPoller that returns either GenerateCredentialsResult or the result - of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("GenerateCredentialsResult", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.GenerateCredentialsResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.GenerateCredentialsResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_replications_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_replications_operations.py deleted file mode 100644 index 32c9d75781ed..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_replications_operations.py +++ /dev/null @@ -1,958 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Replication or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Replication] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ReplicationListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Replication or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Replication - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication: Union[_models.Replication, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 Replication type or - a IO[bytes] type. Required. - :type replication: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Replication or - IO[bytes] - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, replication_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - replication_name: str, - replication_update_parameters: Union[_models.ReplicationUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(replication_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - ReplicationUpdateParameters type or a IO[bytes] type. Required. - :type replication_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ReplicationUpdateParameters or - IO[bytes] - :return: An instance of LROPoller that returns either Replication or the result of - cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Replication", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Replication].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Replication]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_scope_maps_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_scope_maps_operations.py deleted file mode 100644 index c221e0d5277a..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_scope_maps_operations.py +++ /dev/null @@ -1,961 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMap] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.ScopeMapListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: ScopeMap or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMap - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_create_parameters: Union[_models.ScopeMap, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_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 - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - ScopeMap type or a IO[bytes] type. Required. - :type scope_map_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMap or IO[bytes] - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, scope_map_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - scope_map_name: str, - scope_map_update_parameters: Union[_models.ScopeMapUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(scope_map_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - ScopeMapUpdateParameters type or a IO[bytes] type. Required. - :type scope_map_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.ScopeMapUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either ScopeMap or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("ScopeMap", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.ScopeMap].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.ScopeMap]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_tokens_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_tokens_operations.py deleted file mode 100644 index c8a595fbea9f..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_tokens_operations.py +++ /dev/null @@ -1,960 +0,0 @@ -# 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 io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Token or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Token] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.TokenListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = 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) - - @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 - :return: Token or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Token - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = 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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_create_parameters: Union[_models.Token, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # 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. The name 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_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 - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 Token type or - a IO[bytes] type. Required. - :type token_create_parameters: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Token - or IO[bytes] - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, token_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - token_name: str, - token_update_parameters: Union[_models.TokenUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(token_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - TokenUpdateParameters type or a IO[bytes] type. Required. - :type token_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.TokenUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Token or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Token", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Token].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Token]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_webhooks_operations.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_webhooks_operations.py deleted file mode 100644 index 7435f725e968..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/operations/_webhooks_operations.py +++ /dev/null @@ -1,1276 +0,0 @@ -# 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. -# -------------------------------------------------------------------------- -from io import IOBase -import sys -from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload -import urllib.parse - -from azure.core.exceptions import ( - ClientAuthenticationError, - HttpResponseError, - ResourceExistsError, - ResourceNotFoundError, - ResourceNotModifiedError, - StreamClosedError, - StreamConsumedError, - map_error, -) -from azure.core.paging import ItemPaged -from azure.core.pipeline import PipelineResponse -from azure.core.polling import LROPoller, NoPolling, PollingMethod -from azure.core.rest import HttpRequest, HttpResponse -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 - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore -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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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 - 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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-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}/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 = _url.format(**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_08_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") - self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version") - - @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 - :return: An iterator like instance of either Webhook or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Webhook] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.WebhookListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: Webhook or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.Webhook - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_create_parameters: Union[_models.WebhookCreateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_create_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - WebhookCreateParameters type or a IO[bytes] type. Required. - :type webhook_create_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.WebhookCreateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - def _delete_initial( - self, resource_group_name: str, registry_name: str, webhook_name: str, **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[Iterator[bytes]] = 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 202, 204]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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")) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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 - :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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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( - 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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - 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[None].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore - - def _update_initial( - self, - resource_group_name: str, - registry_name: str, - webhook_name: str, - webhook_update_parameters: Union[_models.WebhookUpdateParameters, IO[bytes]], - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(webhook_update_parameters, (IOBase, 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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200, 201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - 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 == 201: - response_headers["Azure-AsyncOperation"] = self._deserialize( - "str", response.headers.get("Azure-AsyncOperation") - ) - - deserialized = response.stream_download(self._client._pipeline, decompress=_decompress) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @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_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 - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_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[bytes], - *, - 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[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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[bytes]], - **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 - WebhookUpdateParameters type or a IO[bytes] type. Required. - :type webhook_update_parameters: - ~azure.mgmt.containerregistry.v2023_08_01_preview.models.WebhookUpdateParameters or IO[bytes] - :return: An instance of LROPoller that returns either Webhook or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~azure.mgmt.containerregistry.v2023_08_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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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 - ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) - - def get_long_running_output(pipeline_response): - deserialized = self._deserialize("Webhook", pipeline_response.http_response) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - 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[_models.Webhook].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.Webhook]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) - - @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 - :return: EventInfo or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.EventInfo - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @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 - :return: An iterator like instance of either Event or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.containerregistry.v2023_08_01_preview.models.Event] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-01-preview") - ) - cls: ClsType[_models.EventListResult] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 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, - headers=_headers, - params=_params, - ) - _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._api_version - _request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - _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) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_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) - - @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 - :return: CallbackConfig or the result of cls(response) - :rtype: ~azure.mgmt.containerregistry.v2023_08_01_preview.models.CallbackConfig - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 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: str = kwargs.pop( - "api_version", _params.pop("api-version", self._api_version or "2023-08-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, - headers=_headers, - params=_params, - ) - _request.url = self._client.format_url(_request.url) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [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.http_response) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/py.typed b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/py.typed deleted file mode 100644 index e5aff4f83af8..000000000000 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_08_01_preview/py.typed +++ /dev/null @@ -1 +0,0 @@ -# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_11_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_11_01_preview/_version.py index ae876c37f272..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_11_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2023_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "11.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2024_11_01_preview/_version.py b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2024_11_01_preview/_version.py index ae876c37f272..e5754a47ce68 100644 --- a/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2024_11_01_preview/_version.py +++ b/sdk/containerregistry/azure-mgmt-containerregistry/azure/mgmt/containerregistry/v2024_11_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "11.0.0" +VERSION = "1.0.0b1"