From 1d5f2e97e8df1ca652ef9921d1a4a3331fdc8895 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Thu, 22 Sep 2022 18:15:36 +0000 Subject: [PATCH] CodeGen from PR 20775 in Azure/azure-rest-api-specs Merge 836d59680ad8f287acc7560884d50fab65b97f65 into 7d5d1db0c45d6fe0934c97b6a6f9bb34112d42d1 --- .../azure-mgmt-appcontainers/_meta.json | 10 +- .../azure/mgmt/appcontainers/__init__.py | 16 +- .../mgmt/appcontainers/_configuration.py | 46 +- .../_container_apps_api_client.py | 122 +- .../azure/mgmt/appcontainers/_metadata.json | 112 - .../azure/mgmt/appcontainers/_patch.py | 2 +- .../mgmt/appcontainers/_serialization.py | 1970 ++++++++ .../azure/mgmt/appcontainers/_vendor.py | 6 +- .../azure/mgmt/appcontainers/_version.py | 2 +- .../azure/mgmt/appcontainers/aio/__init__.py | 16 +- .../mgmt/appcontainers/aio/_configuration.py | 48 +- .../aio/_container_apps_api_client.py | 122 +- .../azure/mgmt/appcontainers/aio/_patch.py | 2 +- .../appcontainers/aio/operations/__init__.py | 44 +- .../operations/_billing_meters_operations.py | 109 + .../operations/_certificates_operations.py | 486 +- ...ed_environments_certificates_operations.py | 589 +++ ...environments_dapr_components_operations.py | 497 ++ .../_connected_environments_operations.py | 833 ++++ ...nected_environments_storages_operations.py | 406 ++ ..._container_apps_auth_configs_operations.py | 355 +- .../_container_apps_diagnostics_operations.py | 428 ++ .../operations/_container_apps_operations.py | 865 ++-- ...ainer_apps_revision_replicas_operations.py | 153 +- .../_container_apps_revisions_operations.py | 319 +- ...ntainer_apps_source_controls_operations.py | 480 +- .../operations/_dapr_components_operations.py | 404 +- ...aged_environment_diagnostics_operations.py | 185 + ...ged_environments_diagnostics_operations.py | 115 + .../_managed_environments_operations.py | 758 ++- ...anaged_environments_storages_operations.py | 331 +- .../aio/operations/_namespaces_operations.py | 170 +- .../aio/operations/_operations.py | 100 +- .../appcontainers/aio/operations/_patch.py | 20 + .../mgmt/appcontainers/models/__init__.py | 384 +- .../_container_apps_api_client_enums.py | 192 +- .../mgmt/appcontainers/models/_models_py3.py | 4132 +++++++++++------ .../azure/mgmt/appcontainers/models/_patch.py | 20 + .../mgmt/appcontainers/operations/__init__.py | 44 +- .../operations/_billing_meters_operations.py | 139 + .../operations/_certificates_operations.py | 717 +-- ...ed_environments_certificates_operations.py | 776 ++++ ...environments_dapr_components_operations.py | 665 +++ .../_connected_environments_operations.py | 1045 +++++ ...nected_environments_storages_operations.py | 542 +++ ..._container_apps_auth_configs_operations.py | 536 ++- .../_container_apps_diagnostics_operations.py | 598 +++ .../operations/_container_apps_operations.py | 1222 +++-- ...ainer_apps_revision_replicas_operations.py | 242 +- .../_container_apps_revisions_operations.py | 530 ++- ...ntainer_apps_source_controls_operations.py | 677 +-- .../operations/_dapr_components_operations.py | 626 +-- ...aged_environment_diagnostics_operations.py | 252 + ...ged_environments_diagnostics_operations.py | 149 + .../_managed_environments_operations.py | 1068 +++-- ...anaged_environments_storages_operations.py | 511 +- .../operations/_namespaces_operations.py | 231 +- .../appcontainers/operations/_operations.py | 139 +- .../mgmt/appcontainers/operations/_patch.py | 20 + 59 files changed, 19457 insertions(+), 6121 deletions(-) delete mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_metadata.json create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_serialization.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_billing_meters_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_certificates_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_dapr_components_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_storages_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_diagnostics_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environment_diagnostics_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_diagnostics_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_patch.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_patch.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_billing_meters_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_certificates_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_dapr_components_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_storages_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_diagnostics_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environment_diagnostics_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_diagnostics_operations.py create mode 100644 sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_patch.py diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/_meta.json b/sdk/appcontainers/azure-mgmt-appcontainers/_meta.json index 9738b12eb06f1..321fad44a47ac 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/_meta.json +++ b/sdk/appcontainers/azure-mgmt-appcontainers/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "autorest": "3.8.4", "use": [ - "@autorest/python@5.13.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.1.6", + "@autorest/modelerfour@4.23.5" ], - "commit": "32143b0f5f230ee2601e3c5d1990188666a5058d", + "commit": "56dd3d74eec8be91423b9713f985e6174dc3a352", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/app/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.13.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/app/resource-manager/readme.md --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.1.6 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", "readme": "specification/app/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/__init__.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/__init__.py index 962b4a502e4fd..984d644c26bc4 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/__init__.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/__init__.py @@ -10,9 +10,15 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['ContainerAppsAPIClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ContainerAppsAPIClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_configuration.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_configuration.py index 60eb6a5be7b08..cbde29809fff4 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_configuration.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_configuration.py @@ -25,23 +25,18 @@ class ContainerAppsAPIClientConfiguration(Configuration): # pylint: disable=too Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ContainerAppsAPIClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", "2022-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +46,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-appcontainers/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appcontainers/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_container_apps_api_client.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_container_apps_api_client.py index 3dd561f1c96c6..78403f346d008 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_container_apps_api_client.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_container_apps_api_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models from ._configuration import ContainerAppsAPIClientConfiguration -from .operations import CertificatesOperations, ContainerAppsAuthConfigsOperations, ContainerAppsOperations, ContainerAppsRevisionReplicasOperations, ContainerAppsRevisionsOperations, ContainerAppsSourceControlsOperations, DaprComponentsOperations, ManagedEnvironmentsOperations, ManagedEnvironmentsStoragesOperations, NamespacesOperations, Operations +from ._serialization import Deserializer, Serializer +from .operations import ( + BillingMetersOperations, + CertificatesOperations, + ConnectedEnvironmentsCertificatesOperations, + ConnectedEnvironmentsDaprComponentsOperations, + ConnectedEnvironmentsOperations, + ConnectedEnvironmentsStoragesOperations, + ContainerAppsAuthConfigsOperations, + ContainerAppsDiagnosticsOperations, + ContainerAppsOperations, + ContainerAppsRevisionReplicasOperations, + ContainerAppsRevisionsOperations, + ContainerAppsSourceControlsOperations, + DaprComponentsOperations, + ManagedEnvironmentDiagnosticsOperations, + ManagedEnvironmentsDiagnosticsOperations, + ManagedEnvironmentsOperations, + ManagedEnvironmentsStoragesOperations, + NamespacesOperations, + Operations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class ContainerAppsAPIClient: # pylint: disable=too-many-instance-attributes + +class ContainerAppsAPIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerAppsAPIClient. :ivar container_apps_auth_configs: ContainerAppsAuthConfigsOperations operations @@ -38,6 +58,15 @@ class ContainerAppsAPIClient: # pylint: disable=too-many-instance-attributes azure.mgmt.appcontainers.operations.ContainerAppsRevisionReplicasOperations :ivar dapr_components: DaprComponentsOperations operations :vartype dapr_components: azure.mgmt.appcontainers.operations.DaprComponentsOperations + :ivar container_apps_diagnostics: ContainerAppsDiagnosticsOperations operations + :vartype container_apps_diagnostics: + azure.mgmt.appcontainers.operations.ContainerAppsDiagnosticsOperations + :ivar managed_environment_diagnostics: ManagedEnvironmentDiagnosticsOperations operations + :vartype managed_environment_diagnostics: + azure.mgmt.appcontainers.operations.ManagedEnvironmentDiagnosticsOperations + :ivar managed_environments_diagnostics: ManagedEnvironmentsDiagnosticsOperations operations + :vartype managed_environments_diagnostics: + azure.mgmt.appcontainers.operations.ManagedEnvironmentsDiagnosticsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.appcontainers.operations.Operations :ivar managed_environments: ManagedEnvironmentsOperations operations @@ -53,14 +82,30 @@ class ContainerAppsAPIClient: # pylint: disable=too-many-instance-attributes :ivar container_apps_source_controls: ContainerAppsSourceControlsOperations operations :vartype container_apps_source_controls: azure.mgmt.appcontainers.operations.ContainerAppsSourceControlsOperations - :param credential: Credential needed for the client to connect to Azure. + :ivar connected_environments: ConnectedEnvironmentsOperations operations + :vartype connected_environments: + azure.mgmt.appcontainers.operations.ConnectedEnvironmentsOperations + :ivar connected_environments_certificates: ConnectedEnvironmentsCertificatesOperations + operations + :vartype connected_environments_certificates: + azure.mgmt.appcontainers.operations.ConnectedEnvironmentsCertificatesOperations + :ivar connected_environments_dapr_components: ConnectedEnvironmentsDaprComponentsOperations + operations + :vartype connected_environments_dapr_components: + azure.mgmt.appcontainers.operations.ConnectedEnvironmentsDaprComponentsOperations + :ivar connected_environments_storages: ConnectedEnvironmentsStoragesOperations operations + :vartype connected_environments_storages: + azure.mgmt.appcontainers.operations.ConnectedEnvironmentsStoragesOperations + :ivar billing_meters: BillingMetersOperations operations + :vartype billing_meters: azure.mgmt.appcontainers.operations.BillingMetersOperations + :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. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-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. @@ -73,31 +118,62 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerAppsAPIClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerAppsAPIClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.container_apps_auth_configs = ContainerAppsAuthConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_apps_auth_configs = ContainerAppsAuthConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.container_apps = ContainerAppsOperations(self._client, self._config, self._serialize, self._deserialize) - self.container_apps_revisions = ContainerAppsRevisionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.container_apps_revision_replicas = ContainerAppsRevisionReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_apps_revisions = ContainerAppsRevisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.container_apps_revision_replicas = ContainerAppsRevisionReplicasOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.dapr_components = DaprComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_apps_diagnostics = ContainerAppsDiagnosticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_environment_diagnostics = ManagedEnvironmentDiagnosticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_environments_diagnostics = ManagedEnvironmentsDiagnosticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.managed_environments = ManagedEnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_environments = ManagedEnvironmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_environments_storages = ManagedEnvironmentsStoragesOperations(self._client, self._config, self._serialize, self._deserialize) - self.container_apps_source_controls = ContainerAppsSourceControlsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + self.managed_environments_storages = ManagedEnvironmentsStoragesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.container_apps_source_controls = ContainerAppsSourceControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments = ConnectedEnvironmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments_certificates = ConnectedEnvironmentsCertificatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments_dapr_components = ConnectedEnvironmentsDaprComponentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments_storages = ConnectedEnvironmentsStoragesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.billing_meters = BillingMetersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -106,7 +182,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_metadata.json b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_metadata.json deleted file mode 100644 index ef96a7b752515..0000000000000 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_metadata.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "chosen_version": "2022-03-01", - "total_api_version_list": ["2022-03-01"], - "client": { - "name": "ContainerAppsAPIClient", - "filename": "_container_apps_api_client", - "description": "ContainerAppsAPIClient.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerAppsAPIClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"ContainerAppsAPIClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "container_apps_auth_configs": "ContainerAppsAuthConfigsOperations", - "container_apps": "ContainerAppsOperations", - "container_apps_revisions": "ContainerAppsRevisionsOperations", - "container_apps_revision_replicas": "ContainerAppsRevisionReplicasOperations", - "dapr_components": "DaprComponentsOperations", - "operations": "Operations", - "managed_environments": "ManagedEnvironmentsOperations", - "certificates": "CertificatesOperations", - "namespaces": "NamespacesOperations", - "managed_environments_storages": "ManagedEnvironmentsStoragesOperations", - "container_apps_source_controls": "ContainerAppsSourceControlsOperations" - } -} \ No newline at end of file diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_patch.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_patch.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_serialization.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_serialization.py new file mode 100644 index 0000000000000..7c1dedb5133d3 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + else: # That's a basic type + # Integrate namespace if necessary + local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) + local_node.text = unicode_str(new_attr) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + except (AttributeError, KeyError, TypeError) as err: + msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) + raise_with_traceback(SerializationError, msg, err) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise_with_traceback(SerializationError, msg.format(data, data_type), err) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) + if obj_type is _long_type: + return self.serialize_long(attr) + if obj_type is unicode_str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + # https://github.com/Azure/msrest-for-python/issues/197 + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") + + def __init__(self, classes=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = dict(classes) if classes else {} + self.key_extractors = [rest_key_extractor, xml_key_extractor] + # Additional properties only works if the "rest_key_extractor" is used to + # extract the keys. Making it to work whatever the key extractor is too much + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise_with_traceback(DeserializationError, msg, err) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + # https://github.com/Azure/azure-rest-api-specs/issues/141 + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. + return isodate.parse_date(attr, defaultmonth=None, defaultday=None) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_vendor.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_vendor.py index 138f663c53a4e..9aad73fc743e7 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_vendor.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_vendor.py @@ -7,6 +7,7 @@ from azure.core.pipeline.transport import HttpRequest + def _convert_request(request, files=None): data = request.content if not files else None request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_version.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_version.py index c47f66669f1bf..e5754a47ce68f 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_version.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/__init__.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/__init__.py index cb4bbcce8e12d..7532ceec9286a 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/__init__.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/__init__.py @@ -7,9 +7,15 @@ # -------------------------------------------------------------------------- from ._container_apps_api_client import ContainerAppsAPIClient -__all__ = ['ContainerAppsAPIClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = ["ContainerAppsAPIClient"] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_configuration.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_configuration.py index 8c3aafe443987..5ed33657cd90c 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_configuration.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_configuration.py @@ -25,23 +25,18 @@ class ContainerAppsAPIClientConfiguration(Configuration): # pylint: disable=too Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-06-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(ContainerAppsAPIClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", "2022-06-01-preview") # type: str if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +46,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-appcontainers/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-appcontainers/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_container_apps_api_client.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_container_apps_api_client.py index 99da7f7ccaf79..cb9b12a5c513c 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_container_apps_api_client.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_container_apps_api_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import ContainerAppsAPIClientConfiguration -from .operations import CertificatesOperations, ContainerAppsAuthConfigsOperations, ContainerAppsOperations, ContainerAppsRevisionReplicasOperations, ContainerAppsRevisionsOperations, ContainerAppsSourceControlsOperations, DaprComponentsOperations, ManagedEnvironmentsOperations, ManagedEnvironmentsStoragesOperations, NamespacesOperations, Operations +from .operations import ( + BillingMetersOperations, + CertificatesOperations, + ConnectedEnvironmentsCertificatesOperations, + ConnectedEnvironmentsDaprComponentsOperations, + ConnectedEnvironmentsOperations, + ConnectedEnvironmentsStoragesOperations, + ContainerAppsAuthConfigsOperations, + ContainerAppsDiagnosticsOperations, + ContainerAppsOperations, + ContainerAppsRevisionReplicasOperations, + ContainerAppsRevisionsOperations, + ContainerAppsSourceControlsOperations, + DaprComponentsOperations, + ManagedEnvironmentDiagnosticsOperations, + ManagedEnvironmentsDiagnosticsOperations, + ManagedEnvironmentsOperations, + ManagedEnvironmentsStoragesOperations, + NamespacesOperations, + Operations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class ContainerAppsAPIClient: # pylint: disable=too-many-instance-attributes + +class ContainerAppsAPIClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """ContainerAppsAPIClient. :ivar container_apps_auth_configs: ContainerAppsAuthConfigsOperations operations @@ -38,6 +58,15 @@ class ContainerAppsAPIClient: # pylint: disable=too-many-instance-attributes azure.mgmt.appcontainers.aio.operations.ContainerAppsRevisionReplicasOperations :ivar dapr_components: DaprComponentsOperations operations :vartype dapr_components: azure.mgmt.appcontainers.aio.operations.DaprComponentsOperations + :ivar container_apps_diagnostics: ContainerAppsDiagnosticsOperations operations + :vartype container_apps_diagnostics: + azure.mgmt.appcontainers.aio.operations.ContainerAppsDiagnosticsOperations + :ivar managed_environment_diagnostics: ManagedEnvironmentDiagnosticsOperations operations + :vartype managed_environment_diagnostics: + azure.mgmt.appcontainers.aio.operations.ManagedEnvironmentDiagnosticsOperations + :ivar managed_environments_diagnostics: ManagedEnvironmentsDiagnosticsOperations operations + :vartype managed_environments_diagnostics: + azure.mgmt.appcontainers.aio.operations.ManagedEnvironmentsDiagnosticsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.appcontainers.aio.operations.Operations :ivar managed_environments: ManagedEnvironmentsOperations operations @@ -53,14 +82,30 @@ class ContainerAppsAPIClient: # pylint: disable=too-many-instance-attributes :ivar container_apps_source_controls: ContainerAppsSourceControlsOperations operations :vartype container_apps_source_controls: azure.mgmt.appcontainers.aio.operations.ContainerAppsSourceControlsOperations - :param credential: Credential needed for the client to connect to Azure. + :ivar connected_environments: ConnectedEnvironmentsOperations operations + :vartype connected_environments: + azure.mgmt.appcontainers.aio.operations.ConnectedEnvironmentsOperations + :ivar connected_environments_certificates: ConnectedEnvironmentsCertificatesOperations + operations + :vartype connected_environments_certificates: + azure.mgmt.appcontainers.aio.operations.ConnectedEnvironmentsCertificatesOperations + :ivar connected_environments_dapr_components: ConnectedEnvironmentsDaprComponentsOperations + operations + :vartype connected_environments_dapr_components: + azure.mgmt.appcontainers.aio.operations.ConnectedEnvironmentsDaprComponentsOperations + :ivar connected_environments_storages: ConnectedEnvironmentsStoragesOperations operations + :vartype connected_environments_storages: + azure.mgmt.appcontainers.aio.operations.ConnectedEnvironmentsStoragesOperations + :ivar billing_meters: BillingMetersOperations operations + :vartype billing_meters: azure.mgmt.appcontainers.aio.operations.BillingMetersOperations + :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. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2022-03-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2022-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. @@ -73,31 +118,62 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = ContainerAppsAPIClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = ContainerAppsAPIClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.container_apps_auth_configs = ContainerAppsAuthConfigsOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_apps_auth_configs = ContainerAppsAuthConfigsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.container_apps = ContainerAppsOperations(self._client, self._config, self._serialize, self._deserialize) - self.container_apps_revisions = ContainerAppsRevisionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.container_apps_revision_replicas = ContainerAppsRevisionReplicasOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_apps_revisions = ContainerAppsRevisionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.container_apps_revision_replicas = ContainerAppsRevisionReplicasOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.dapr_components = DaprComponentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.container_apps_diagnostics = ContainerAppsDiagnosticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_environment_diagnostics = ManagedEnvironmentDiagnosticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.managed_environments_diagnostics = ManagedEnvironmentsDiagnosticsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.managed_environments = ManagedEnvironmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.managed_environments = ManagedEnvironmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) - self.managed_environments_storages = ManagedEnvironmentsStoragesOperations(self._client, self._config, self._serialize, self._deserialize) - self.container_apps_source_controls = ContainerAppsSourceControlsOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.managed_environments_storages = ManagedEnvironmentsStoragesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.container_apps_source_controls = ContainerAppsSourceControlsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments = ConnectedEnvironmentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments_certificates = ConnectedEnvironmentsCertificatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments_dapr_components = ConnectedEnvironmentsDaprComponentsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.connected_environments_storages = ConnectedEnvironmentsStoragesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.billing_meters = BillingMetersOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -106,7 +182,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_patch.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_patch.py index 74e48ecd07cf3..f99e77fef9861 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_patch.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/_patch.py @@ -28,4 +28,4 @@ # This file is used for handwritten extensions to the generated code. Example: # https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md def patch_sdk(): - pass \ No newline at end of file + pass diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/__init__.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/__init__.py index 505be253220b7..38342a997743c 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/__init__.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/__init__.py @@ -11,23 +11,45 @@ from ._container_apps_revisions_operations import ContainerAppsRevisionsOperations from ._container_apps_revision_replicas_operations import ContainerAppsRevisionReplicasOperations from ._dapr_components_operations import DaprComponentsOperations +from ._container_apps_diagnostics_operations import ContainerAppsDiagnosticsOperations +from ._managed_environment_diagnostics_operations import ManagedEnvironmentDiagnosticsOperations +from ._managed_environments_diagnostics_operations import ManagedEnvironmentsDiagnosticsOperations from ._operations import Operations from ._managed_environments_operations import ManagedEnvironmentsOperations from ._certificates_operations import CertificatesOperations from ._namespaces_operations import NamespacesOperations from ._managed_environments_storages_operations import ManagedEnvironmentsStoragesOperations from ._container_apps_source_controls_operations import ContainerAppsSourceControlsOperations +from ._connected_environments_operations import ConnectedEnvironmentsOperations +from ._connected_environments_certificates_operations import ConnectedEnvironmentsCertificatesOperations +from ._connected_environments_dapr_components_operations import ConnectedEnvironmentsDaprComponentsOperations +from ._connected_environments_storages_operations import ConnectedEnvironmentsStoragesOperations +from ._billing_meters_operations import BillingMetersOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ContainerAppsAuthConfigsOperations', - 'ContainerAppsOperations', - 'ContainerAppsRevisionsOperations', - 'ContainerAppsRevisionReplicasOperations', - 'DaprComponentsOperations', - 'Operations', - 'ManagedEnvironmentsOperations', - 'CertificatesOperations', - 'NamespacesOperations', - 'ManagedEnvironmentsStoragesOperations', - 'ContainerAppsSourceControlsOperations', + "ContainerAppsAuthConfigsOperations", + "ContainerAppsOperations", + "ContainerAppsRevisionsOperations", + "ContainerAppsRevisionReplicasOperations", + "DaprComponentsOperations", + "ContainerAppsDiagnosticsOperations", + "ManagedEnvironmentDiagnosticsOperations", + "ManagedEnvironmentsDiagnosticsOperations", + "Operations", + "ManagedEnvironmentsOperations", + "CertificatesOperations", + "NamespacesOperations", + "ManagedEnvironmentsStoragesOperations", + "ContainerAppsSourceControlsOperations", + "ConnectedEnvironmentsOperations", + "ConnectedEnvironmentsCertificatesOperations", + "ConnectedEnvironmentsDaprComponentsOperations", + "ConnectedEnvironmentsStoragesOperations", + "BillingMetersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_billing_meters_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_billing_meters_operations.py new file mode 100644 index 0000000000000..ef8b13a0f2614 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_billing_meters_operations.py @@ -0,0 +1,109 @@ +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._billing_meters_operations import build_get_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BillingMetersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`billing_meters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, location: str, **kwargs: Any) -> _models.BillingMeterCollection: + """Get billing meters by location. + + Get all billingMeters for a location. + + :param location: The name of Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingMeterCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.BillingMeterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BillingMeterCollection] + + request = build_get_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BillingMeterCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/locations/{location}/billingMeters"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_certificates_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_certificates_operations.py index f4742e78a51a5..c3fa29537bb1a 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_certificates_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_certificates_operations.py @@ -6,98 +6,114 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CertificatesOperations: - """CertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CertificateCollection"]: + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Certificate"]: """Get the Certificates in a given managed environment. Get the Certificates in a given managed environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.CertificateCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Certificate or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.Certificate] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - environment_name=environment_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,10 +127,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,60 +139,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - environment_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.Certificate": + self, resource_group_name: str, environment_name: str, certificate_name: str, **kwargs: Any + ) -> _models.Certificate: """Get the specified Certificate. Get the specified Certificate. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Certificate, or the result of cls(response) + :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Certificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,74 +201,158 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Certificate', pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, environment_name: str, certificate_name: str, - certificate_envelope: Optional["_models.Certificate"] = None, + certificate_envelope: Optional[_models.Certificate] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Create or Update a Certificate. Create or Update a Certificate. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str :param certificate_envelope: Certificate to be created or updated. Default value is None. :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Default value is None. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: Optional[Union[_models.Certificate, IO]] = None, + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Is either a model type or a + IO type. Default value is None. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Certificate, or the result of cls(response) + :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Certificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] - if certificate_envelope is not None: - _json = self._serialize.body(certificate_envelope, 'Certificate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope else: - _json = None + if certificate_envelope is not None: + _json = self._serialize.body(certificate_envelope, "Certificate") + else: + _json = None request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -261,64 +360,66 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Certificate', pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, certificate_name: str, **kwargs: Any ) -> None: """Deletes the specified Certificate. Deletes the specified Certificate. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -329,8 +430,73 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: _models.CertificatePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( @@ -338,55 +504,74 @@ async def update( resource_group_name: str, environment_name: str, certificate_name: str, - certificate_envelope: "_models.CertificatePatch", + certificate_envelope: Union[_models.CertificatePatch, IO], **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Update properties of a certificate. Patches a certificate. Currently only patching of tags is supported. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str - :param certificate_envelope: Properties of a certificate that need to be updated. - :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch + :param certificate_envelope: Properties of a certificate that need to be updated. Is either a + model type or a IO type. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Certificate, or the result of cls(response) + :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Certificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] - _json = self._serialize.body(certificate_envelope, 'CertificatePatch') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope + else: + _json = self._serialize.body(certificate_envelope, "CertificatePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -394,12 +579,11 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Certificate', pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_certificates_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_certificates_operations.py new file mode 100644 index 0000000000000..4d23e3368f2d3 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_certificates_operations.py @@ -0,0 +1,589 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._connected_environments_certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConnectedEnvironmentsCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`connected_environments_certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Certificate"]: + """Get the Certificates in a given connected environment. + + Get the Certificates in a given connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Certificate or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.Certificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, connected_environment_name: str, certificate_name: str, **kwargs: Any + ) -> _models.Certificate: + """Get the specified Certificate. + + Get the specified Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Certificate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Optional[_models.Certificate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Default value is None. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Default value is None. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Optional[Union[_models.Certificate, IO]] = None, + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Is either a model type or a + IO type. Default value is None. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope + else: + if certificate_envelope is not None: + _json = self._serialize.body(certificate_envelope, "Certificate") + else: + _json = None + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Certificate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, certificate_name: str, **kwargs: Any + ) -> None: + """Deletes the specified Certificate. + + Deletes the specified Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: _models.CertificatePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Union[_models.CertificatePatch, IO], + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Is either a + model type or a IO type. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope + else: + _json = self._serialize.body(certificate_envelope, "CertificatePatch") + + request = build_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Certificate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_dapr_components_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_dapr_components_operations.py new file mode 100644 index 0000000000000..d9a30bc9c8b60 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_dapr_components_operations.py @@ -0,0 +1,497 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._connected_environments_dapr_components_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_list_secrets_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConnectedEnvironmentsDaprComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`connected_environments_dapr_components` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DaprComponent"]: + """Get the Dapr Components for a connected environment. + + Get the Dapr Components for a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DaprComponent or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.DaprComponent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponentsCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DaprComponentsCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, connected_environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprComponent: + """Get a dapr component. + + Get a dapr component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DaprComponent", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + component_name: str, + dapr_component_envelope: _models.DaprComponent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + component_name: str, + dapr_component_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + component_name: str, + dapr_component_envelope: Union[_models.DaprComponent, IO], + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Is either a model + type or a IO type. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dapr_component_envelope, (IO, bytes)): + _content = dapr_component_envelope + else: + _json = self._serialize.body(dapr_component_envelope, "DaprComponent") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DaprComponent", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, component_name: str, **kwargs: Any + ) -> None: + """Delete a Dapr Component. + + Delete a Dapr Component from a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}"} # type: ignore + + @distributed_trace_async + async def list_secrets( + self, resource_group_name: str, connected_environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprSecretsCollection: + """List secrets for a dapr component. + + List secrets for a dapr component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprSecretsCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprSecretsCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprSecretsCollection] + + request = build_list_secrets_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DaprSecretsCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}/listSecrets"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_operations.py new file mode 100644 index 0000000000000..abca55a4e5214 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_operations.py @@ -0,0 +1,833 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._connected_environments_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConnectedEnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`connected_environments` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ConnectedEnvironment"]: + """Get all connectedEnvironments for a subscription. + + Get all connectedEnvironments for a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedEnvironment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedEnvironmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/connectedEnvironments"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ConnectedEnvironment"]: + """Get all connectedEnvironments in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedEnvironment or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedEnvironmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironment: + """Get the properties of an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironment or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: Union[_models.ConnectedEnvironment, IO], + **kwargs: Any + ) -> _models.ConnectedEnvironment: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(environment_envelope, (IO, bytes)): + _content = environment_envelope + else: + _json = self._serialize.body(environment_envelope, "ConnectedEnvironment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: _models.ConnectedEnvironment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedEnvironment]: + """Creates or updates an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :param environment_envelope: Configuration details of the connectedEnvironment. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConnectedEnvironment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedEnvironment]: + """Creates or updates an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :param environment_envelope: Configuration details of the connectedEnvironment. Required. + :type environment_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConnectedEnvironment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: Union[_models.ConnectedEnvironment, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ConnectedEnvironment]: + """Creates or updates an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :param environment_envelope: Configuration details of the connectedEnvironment. Is either a + model type or a IO type. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ConnectedEnvironment or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + environment_envelope=environment_envelope, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Delete an connectedEnvironment. + + Delete an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @distributed_trace_async + async def update( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironment: + """Update connected Environment's properties. + + Patches a Managed Environment. Only patching of tags is supported currently. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironment or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + + request = build_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @overload + async def check_name_availability( + self, + resource_group_name: str, + connected_environment_name: str, + check_name_availability_request: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource connectedEnvironmentName availability. + + Checks if resource connectedEnvironmentName is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Managed Environment. Required. + :type connected_environment_name: str + :param check_name_availability_request: The check connectedEnvironmentName availability + request. Required. + :type check_name_availability_request: + ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + connected_environment_name: str, + check_name_availability_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource connectedEnvironmentName availability. + + Checks if resource connectedEnvironmentName is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Managed Environment. Required. + :type connected_environment_name: str + :param check_name_availability_request: The check connectedEnvironmentName availability + request. Required. + :type check_name_availability_request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + connected_environment_name: str, + check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource connectedEnvironmentName availability. + + Checks if resource connectedEnvironmentName is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Managed Environment. Required. + :type connected_environment_name: str + :param check_name_availability_request: The check connectedEnvironmentName availability + request. Is either a model type or a IO type. Required. + :type check_name_availability_request: + ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_request, (IO, bytes)): + _content = check_name_availability_request + else: + _json = self._serialize.body(check_name_availability_request, "CheckNameAvailabilityRequest") + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/checkNameAvailability"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_storages_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_storages_operations.py new file mode 100644 index 0000000000000..37630e7e29bcf --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_connected_environments_storages_operations.py @@ -0,0 +1,406 @@ +# 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 typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._connected_environments_storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ConnectedEnvironmentsStoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`connected_environments_storages` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironmentStoragesCollection: + """Get all storages for a connectedEnvironment. + + Get all storages for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStoragesCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStoragesCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentStoragesCollection] + + request = build_list_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironmentStoragesCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, connected_environment_name: str, storage_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Get storage for a connectedEnvironment. + + Get storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentStorage] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + storage_name=storage_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironmentStorage", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + storage_name: str, + storage_envelope: _models.ConnectedEnvironmentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Create or update storage for a connectedEnvironment. + + Create or update storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + storage_name: str, + storage_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Create or update storage for a connectedEnvironment. + + Create or update storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + storage_name: str, + storage_envelope: Union[_models.ConnectedEnvironmentStorage, IO], + **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Create or update storage for a connectedEnvironment. + + Create or update storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Is either a model type or a IO type. + Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentStorage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_envelope, (IO, bytes)): + _content = storage_envelope + else: + _json = self._serialize.body(storage_envelope, "ConnectedEnvironmentStorage") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + storage_name=storage_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironmentStorage", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, storage_name: str, **kwargs: Any + ) -> None: + """Delete storage for a connectedEnvironment. + + Delete storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + storage_name=storage_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_auth_configs_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_auth_configs_operations.py index 3b3fc84f50d7f..67857e8db5bb4 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_auth_configs_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_auth_configs_operations.py @@ -6,98 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._container_apps_auth_configs_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_container_app_request -T = TypeVar('T') +from ...operations._container_apps_auth_configs_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_container_app_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainerAppsAuthConfigsOperations: - """ContainerAppsAuthConfigsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainerAppsAuthConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`container_apps_auth_configs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_container_app( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.AuthConfigCollection"]: + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AuthConfig"]: """Get the Container App AuthConfigs in a given resource group. Get the Container App AuthConfigs in a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthConfigCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.AuthConfigCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AuthConfig or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.AuthConfig] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthConfigCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthConfigCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_container_app.metadata['url'], + template_url=self.list_by_container_app.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - container_app_name=container_app_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,10 +126,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,60 +138,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_container_app.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs"} # type: ignore + list_by_container_app.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - container_app_name: str, - auth_config_name: str, - **kwargs: Any - ) -> "_models.AuthConfig": + self, resource_group_name: str, container_app_name: str, auth_config_name: str, **kwargs: Any + ) -> _models.AuthConfig: """Get a AuthConfig of a Container App. Get a AuthConfig of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param auth_config_name: Name of the Container App AuthConfig. + :param auth_config_name: Name of the Container App AuthConfig. Required. :type auth_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthConfig, or the result of cls(response) + :return: AuthConfig or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.AuthConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthConfig] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, auth_config_name=auth_config_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,15 +200,80 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthConfig', pipeline_response) + deserialized = self._deserialize("AuthConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + container_app_name: str, + auth_config_name: str, + auth_config_envelope: _models.AuthConfig, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthConfig: + """Create or update the AuthConfig for a Container App. + + Create or update the AuthConfig for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param auth_config_name: Name of the Container App AuthConfig. Required. + :type auth_config_name: str + :param auth_config_envelope: Properties used to create a Container App AuthConfig. Required. + :type auth_config_envelope: ~azure.mgmt.appcontainers.models.AuthConfig + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthConfig or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.AuthConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + container_app_name: str, + auth_config_name: str, + auth_config_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthConfig: + """Create or update the AuthConfig for a Container App. + Create or update the AuthConfig for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param auth_config_name: Name of the Container App AuthConfig. Required. + :type auth_config_name: str + :param auth_config_envelope: Properties used to create a Container App AuthConfig. Required. + :type auth_config_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthConfig or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.AuthConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -202,55 +281,74 @@ async def create_or_update( resource_group_name: str, container_app_name: str, auth_config_name: str, - auth_config_envelope: "_models.AuthConfig", + auth_config_envelope: Union[_models.AuthConfig, IO], **kwargs: Any - ) -> "_models.AuthConfig": + ) -> _models.AuthConfig: """Create or update the AuthConfig for a Container App. - Description for Create or update the AuthConfig for a Container App. + Create or update the AuthConfig for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param auth_config_name: Name of the Container App AuthConfig. + :param auth_config_name: Name of the Container App AuthConfig. Required. :type auth_config_name: str - :param auth_config_envelope: Properties used to create a Container App AuthConfig. - :type auth_config_envelope: ~azure.mgmt.appcontainers.models.AuthConfig + :param auth_config_envelope: Properties used to create a Container App AuthConfig. Is either a + model type or a IO type. Required. + :type auth_config_envelope: ~azure.mgmt.appcontainers.models.AuthConfig or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthConfig, or the result of cls(response) + :return: AuthConfig or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.AuthConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthConfig] - _json = self._serialize.body(auth_config_envelope, 'AuthConfig') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(auth_config_envelope, (IO, bytes)): + _content = auth_config_envelope + else: + _json = self._serialize.body(auth_config_envelope, "AuthConfig") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, auth_config_name=auth_config_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -258,64 +356,66 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthConfig', pipeline_response) + deserialized = self._deserialize("AuthConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - auth_config_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, auth_config_name: str, **kwargs: Any ) -> None: """Delete a Container App AuthConfig. - Description for Delete a Container App AuthConfig. + Delete a Container App AuthConfig. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param auth_config_name: Name of the Container App AuthConfig. + :param auth_config_name: Name of the Container App AuthConfig. Required. :type auth_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, auth_config_name=auth_config_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -326,5 +426,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_diagnostics_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_diagnostics_operations.py new file mode 100644 index 0000000000000..29c9bb680bd2b --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_diagnostics_operations.py @@ -0,0 +1,428 @@ +# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._container_apps_diagnostics_operations import ( + build_get_detector_request, + build_get_revision_request, + build_get_root_request, + build_list_detectors_request, + build_list_revisions_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ContainerAppsDiagnosticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`container_apps_diagnostics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_detectors( + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.Diagnostics"]: + """Get the list of diagnostics for a given Container App. + + Get the list of diagnostics for a given Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App for which detector info is needed. + Required. + :type container_app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Diagnostics or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.Diagnostics] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticsCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_detectors_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_detectors.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticsCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_detectors.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectors"} # type: ignore + + @distributed_trace_async + async def get_detector( + self, resource_group_name: str, container_app_name: str, detector_name: str, **kwargs: Any + ) -> _models.Diagnostics: + """Get a diagnostics result of a Container App. + + Get a diagnostics result of a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param detector_name: Name of the Container App Detector. Required. + :type detector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Diagnostics or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Diagnostics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Diagnostics] + + request = build_get_detector_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + detector_name=detector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_detector.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Diagnostics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_detector.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectors/{detectorName}"} # type: ignore + + @distributed_trace + def list_revisions( + self, resource_group_name: str, container_app_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Revision"]: + """Get the Revisions for a given Container App. + + Get the Revisions for a given Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App for which Revisions are needed. Required. + :type container_app_name: str + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Revision or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.Revision] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RevisionCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_revisions_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_revisions.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RevisionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_revisions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/revisionsApi/revisions/"} # type: ignore + + @distributed_trace_async + async def get_revision( + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any + ) -> _models.Revision: + """Get a revision of a Container App. + + Get a revision of a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param revision_name: Name of the Container App Revision. Required. + :type revision_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Revision or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Revision + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Revision] + + request = build_get_revision_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + revision_name=revision_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_revision.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Revision", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/revisionsApi/revisions/{revisionName}"} # type: ignore + + @distributed_trace_async + async def get_root(self, resource_group_name: str, container_app_name: str, **kwargs: Any) -> _models.ContainerApp: + """Get the properties of a Container App. + + Get the properties of a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContainerApp or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ContainerApp + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] + + request = build_get_root_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_root.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerApp", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/rootApi/"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_operations.py index 14252e0ca694a..f83e8ecb44087 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_operations.py @@ -6,90 +6,111 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._container_apps_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_custom_host_name_analysis_request, build_list_secrets_request, build_update_request_initial -T = TypeVar('T') +from ...operations._container_apps_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_auth_token_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_custom_host_name_analysis_request, + build_list_secrets_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainerAppsOperations: - """ContainerAppsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainerAppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`container_apps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ContainerAppCollection"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ContainerApp"]: """Get the Container Apps in a given subscription. Get the Container Apps in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContainerAppCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ContainerAppCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ContainerApp or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerAppCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerAppCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -103,10 +124,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,60 +136,60 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.App/containerApps"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/containerApps"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ContainerAppCollection"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.ContainerApp"]: """Get the Container Apps in a given resource group. Get the Container Apps in a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContainerAppCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ContainerAppCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ContainerApp or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerAppCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerAppCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -184,10 +203,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -198,56 +215,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> "_models.ContainerApp": + async def get(self, resource_group_name: str, container_app_name: str, **kwargs: Any) -> _models.ContainerApp: """Get the properties of a Container App. Get the properties of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContainerApp, or the result of cls(response) + :return: ContainerApp or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ContainerApp - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerApp"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,89 +272,183 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any - ) -> "_models.ContainerApp": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerApp"] + ) -> _models.ContainerApp: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(container_app_envelope, 'ContainerApp') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container_app_envelope, (IO, bytes)): + _content = container_app_envelope + else: + _json = self._serialize.body(container_app_envelope, "ContainerApp") + + request = build_create_or_update_request( resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: _models.ContainerApp, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ContainerApp]: + """Create or update a Container App. + + Create or update a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties used to create a container app. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ContainerApp or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ContainerApp]: + """Create or update a Container App. + Create or update a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties used to create a container app. Required. + :type container_app_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ContainerApp or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ContainerApp"]: + ) -> AsyncLROPoller[_models.ContainerApp]: """Create or update a Container App. - Description for Create or update a Container App. + Create or update a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param container_app_envelope: Properties used to create a container app. - :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :param container_app_envelope: Properties used to create a container app. Is either a model + type or a IO type. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -349,107 +460,111 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either ContainerApp or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ContainerApp] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerApp"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, container_app_envelope=container_app_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, container_app_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a Container App. - Description for Delete a Container App. + Delete a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -461,98 +576,190 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore async def _update_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(container_app_envelope, 'ContainerApp') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container_app_envelope, (IO, bytes)): + _content = container_app_envelope + else: + _json = self._serialize.body(container_app_envelope, "ContainerApp") + + request = build_update_request( resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: _models.ContainerApp, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update properties of a Container App. + + Patches a Container App using JSON Merge Patch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties of a Container App that need to be updated. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update properties of a Container App. + + Patches a Container App using JSON Merge Patch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties of a Container App that need to be updated. Required. + :type container_app_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_update( # pylint: disable=inconsistent-return-statements + async def begin_update( self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Update properties of a Container App. @@ -560,11 +767,16 @@ async def begin_update( # pylint: disable=inconsistent-return-statements Patches a Container App using JSON Merge Patch. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param container_app_envelope: Properties of a Container App that need to be updated. - :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :param container_app_envelope: Properties of a Container App that need to be updated. Is either + a model type or a IO type. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -575,96 +787,103 @@ async def begin_update( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, container_app_envelope=container_app_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore @distributed_trace_async async def list_custom_host_name_analysis( - self, - resource_group_name: str, - container_app_name: str, - custom_hostname: Optional[str] = None, - **kwargs: Any - ) -> "_models.CustomHostnameAnalysisResult": + self, resource_group_name: str, container_app_name: str, custom_hostname: Optional[str] = None, **kwargs: Any + ) -> _models.CustomHostnameAnalysisResult: """Analyzes a custom hostname for a Container App. Analyzes a custom hostname for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :param custom_hostname: Custom hostname. Default value is None. :type custom_hostname: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomHostnameAnalysisResult, or the result of cls(response) + :return: CustomHostnameAnalysisResult or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.CustomHostnameAnalysisResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomHostnameAnalysisResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomHostnameAnalysisResult] - request = build_list_custom_host_name_analysis_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, custom_hostname=custom_hostname, - template_url=self.list_custom_host_name_analysis.metadata['url'], + api_version=api_version, + template_url=self.list_custom_host_name_analysis.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -672,60 +891,63 @@ async def list_custom_host_name_analysis( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomHostnameAnalysisResult', pipeline_response) + deserialized = self._deserialize("CustomHostnameAnalysisResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_custom_host_name_analysis.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listCustomHostNameAnalysis"} # type: ignore - + list_custom_host_name_analysis.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listCustomHostNameAnalysis"} # type: ignore @distributed_trace_async async def list_secrets( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> "_models.SecretsCollection": + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> _models.SecretsCollection: """List secrets for a container app. List secrets for a container app. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecretsCollection, or the result of cls(response) + :return: SecretsCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.SecretsCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecretsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecretsCollection] - request = build_list_secrets_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_secrets.metadata['url'], + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -733,12 +955,75 @@ async def list_secrets( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SecretsCollection', pipeline_response) + deserialized = self._deserialize("SecretsCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listSecrets"} # type: ignore + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listSecrets"} # type: ignore + + @distributed_trace_async + async def get_auth_token( + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> _models.ContainerAppAuthToken: + """Get auth token for a container app. + + Get auth token for a container app. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContainerAppAuthToken or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ContainerAppAuthToken + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerAppAuthToken] + + request = build_get_auth_token_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_auth_token.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerAppAuthToken", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_auth_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/getAuthtoken"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revision_replicas_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revision_replicas_operations.py index be675fe4c67ac..b3d3fa7eb4887 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revision_replicas_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revision_replicas_operations.py @@ -8,93 +8,105 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._container_apps_revision_replicas_operations import build_get_replica_request, build_list_replicas_request -T = TypeVar('T') +from ...operations._container_apps_revision_replicas_operations import ( + build_get_replica_request, + build_list_replicas_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainerAppsRevisionReplicasOperations: - """ContainerAppsRevisionReplicasOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainerAppsRevisionReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`container_apps_revision_replicas` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get_replica( - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - replica_name: str, - **kwargs: Any - ) -> "_models.Replica": + self, resource_group_name: str, container_app_name: str, revision_name: str, replica_name: str, **kwargs: Any + ) -> _models.Replica: """Get a replica for a Container App Revision. Get a replica for a Container App Revision. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str - :param replica_name: Name of the Container App Revision Replica. + :param replica_name: Name of the Container App Revision Replica. Required. :type replica_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replica, or the result of cls(response) + :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Replica - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replica"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Replica] - request = build_get_replica_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, replica_name=replica_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_replica.metadata['url'], + template_url=self.get_replica.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,64 +114,66 @@ async def get_replica( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replica', pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_replica.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas/{replicaName}"} # type: ignore - + get_replica.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas/{replicaName}"} # type: ignore @distributed_trace_async async def list_replicas( - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any - ) -> "_models.ReplicaCollection": + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any + ) -> _models.ReplicaCollection: """List replicas for a Container App Revision. List replicas for a Container App Revision. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReplicaCollection, or the result of cls(response) + :return: ReplicaCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ReplicaCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicaCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplicaCollection] - request = build_list_replicas_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_replicas.metadata['url'], + template_url=self.list_replicas.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -167,12 +181,11 @@ async def list_replicas( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ReplicaCollection', pipeline_response) + deserialized = self._deserialize("ReplicaCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_replicas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas"} # type: ignore - + list_replicas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revisions_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revisions_operations.py index e89886bbb4aa9..5b78642d2c07e 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revisions_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_revisions_operations.py @@ -7,101 +7,116 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._container_apps_revisions_operations import build_activate_revision_request, build_deactivate_revision_request, build_get_revision_request, build_list_revisions_request, build_restart_revision_request -T = TypeVar('T') +from ...operations._container_apps_revisions_operations import ( + build_activate_revision_request, + build_deactivate_revision_request, + build_get_revision_request, + build_list_revisions_request, + build_restart_revision_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainerAppsRevisionsOperations: - """ContainerAppsRevisionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainerAppsRevisionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`container_apps_revisions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_revisions( - self, - resource_group_name: str, - container_app_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterable["_models.RevisionCollection"]: + self, resource_group_name: str, container_app_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> AsyncIterable["_models.Revision"]: """Get the Revisions for a given Container App. Get the Revisions for a given Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App for which Revisions are needed. + :param container_app_name: Name of the Container App for which Revisions are needed. Required. :type container_app_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RevisionCollection or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.RevisionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Revision or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.Revision] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RevisionCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RevisionCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_revisions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_revisions.metadata['url'], + api_version=api_version, + template_url=self.list_revisions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_revisions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - container_app_name=container_app_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -115,10 +130,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -129,60 +142,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_revisions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions"} # type: ignore + list_revisions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions"} # type: ignore @distributed_trace_async async def get_revision( - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any - ) -> "_models.Revision": + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any + ) -> _models.Revision: """Get a revision of a Container App. Get a revision of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Revision, or the result of cls(response) + :return: Revision or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Revision - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Revision"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Revision] - request = build_get_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_revision.metadata['url'], + template_url=self.get_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -190,64 +204,66 @@ async def get_revision( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Revision', pipeline_response) + deserialized = self._deserialize("Revision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}"} # type: ignore - + get_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}"} # type: ignore @distributed_trace_async async def activate_revision( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any ) -> None: """Activates a revision for a Container App. Activates a revision for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_activate_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.activate_revision.metadata['url'], + template_url=self.activate_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -258,57 +274,59 @@ async def activate_revision( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - activate_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/activate"} # type: ignore - + activate_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/activate"} # type: ignore @distributed_trace_async async def deactivate_revision( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any ) -> None: """Deactivates a revision for a Container App. Deactivates a revision for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deactivate_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.deactivate_revision.metadata['url'], + template_url=self.deactivate_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -319,57 +337,59 @@ async def deactivate_revision( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - deactivate_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/deactivate"} # type: ignore - + deactivate_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/deactivate"} # type: ignore @distributed_trace_async async def restart_revision( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any ) -> None: """Restarts a revision for a Container App. Restarts a revision for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_restart_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.restart_revision.metadata['url'], + template_url=self.restart_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -380,5 +400,4 @@ async def restart_revision( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restart_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/restart"} # type: ignore - + restart_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/restart"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_source_controls_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_source_controls_operations.py index bbc66a490a874..e507ed394a806 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_source_controls_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_container_apps_source_controls_operations.py @@ -6,100 +6,115 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._container_apps_source_controls_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_container_app_request -T = TypeVar('T') +from ...operations._container_apps_source_controls_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_container_app_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ContainerAppsSourceControlsOperations: - """ContainerAppsSourceControlsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ContainerAppsSourceControlsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`container_apps_source_controls` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_container_app( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SourceControlCollection"]: + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SourceControl"]: """Get the Container App SourceControls in a given resource group. Get the Container App SourceControls in a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.SourceControlCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SourceControl or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.SourceControl] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControlCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_container_app.metadata['url'], + template_url=self.list_by_container_app.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - container_app_name=container_app_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -113,10 +128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -127,60 +140,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_container_app.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols"} # type: ignore + list_by_container_app.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any - ) -> "_models.SourceControl": + self, resource_group_name: str, container_app_name: str, source_control_name: str, **kwargs: Any + ) -> _models.SourceControl: """Get a SourceControl of a Container App. Get a SourceControl of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param source_control_name: Name of the Container App SourceControl. + :param source_control_name: Name of the Container App SourceControl. Required. :type source_control_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControl, or the result of cls(response) + :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.SourceControl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControl] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -188,94 +202,114 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControl', pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, container_app_name: str, source_control_name: str, - source_control_envelope: "_models.SourceControl", + source_control_envelope: Union[_models.SourceControl, IO], **kwargs: Any - ) -> "_models.SourceControl": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] + ) -> _models.SourceControl: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(source_control_envelope, 'SourceControl') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControl] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_envelope, (IO, bytes)): + _content = source_control_envelope + else: + _json = self._serialize.body(source_control_envelope, "SourceControl") + + request = build_create_or_update_request( resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControl', pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response) - if response.status_code == 202: - deserialized = self._deserialize('SourceControl', pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("SourceControl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, container_app_name: str, source_control_name: str, - source_control_envelope: "_models.SourceControl", + source_control_envelope: _models.SourceControl, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.SourceControl"]: + ) -> AsyncLROPoller[_models.SourceControl]: """Create or update the SourceControl for a Container App. - Description for Create or update the SourceControl for a Container App. + Create or update the SourceControl for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param source_control_name: Name of the Container App SourceControl. + :param source_control_name: Name of the Container App SourceControl. Required. :type source_control_name: str :param source_control_envelope: Properties used to create a Container App SourceControl. + Required. :type source_control_envelope: ~azure.mgmt.appcontainers.models.SourceControl + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -287,113 +321,197 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either SourceControl or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.SourceControl] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + source_control_name: str, + source_control_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SourceControl]: + """Create or update the SourceControl for a Container App. + + Create or update the SourceControl for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param source_control_name: Name of the Container App SourceControl. Required. + :type source_control_name: str + :param source_control_envelope: Properties used to create a Container App SourceControl. + Required. + :type source_control_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SourceControl or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.SourceControl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + source_control_name: str, + source_control_envelope: Union[_models.SourceControl, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.SourceControl]: + """Create or update the SourceControl for a Container App. + + Create or update the SourceControl for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param source_control_name: Name of the Container App SourceControl. Required. + :type source_control_name: str + :param source_control_envelope: Properties used to create a Container App SourceControl. Is + either a model type or a IO type. Required. + :type source_control_envelope: ~azure.mgmt.appcontainers.models.SourceControl or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either SourceControl or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.SourceControl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControl] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, source_control_envelope=source_control_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SourceControl', pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, source_control_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, container_app_name: str, source_control_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a Container App SourceControl. - Description for Delete a Container App SourceControl. + Delete a Container App SourceControl. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param source_control_name: Name of the Container App SourceControl. + :param source_control_name: Name of the Container App SourceControl. Required. :type source_control_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -405,42 +523,46 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_dapr_components_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_dapr_components_operations.py index 549c8275319c3..4f776236c2def 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_dapr_components_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_dapr_components_operations.py @@ -6,98 +6,114 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._dapr_components_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_list_secrets_request -T = TypeVar('T') +from ...operations._dapr_components_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, + build_list_secrets_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DaprComponentsOperations: - """DaprComponentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DaprComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`dapr_components` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.DaprComponentsCollection"]: + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> AsyncIterable["_models.DaprComponent"]: """Get the Dapr Components for a managed environment. Get the Dapr Components for a managed environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DaprComponentsCollection or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.DaprComponentsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DaprComponent or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.DaprComponent] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponentsCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprComponentsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - environment_name=environment_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -111,10 +127,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,60 +139,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any - ) -> "_models.DaprComponent": + self, resource_group_name: str, environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprComponent: """Get a dapr component. Get a dapr component. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DaprComponent, or the result of cls(response) + :return: DaprComponent or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.DaprComponent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprComponent"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -186,15 +201,80 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DaprComponent', pipeline_response) + deserialized = self._deserialize("DaprComponent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + environment_name: str, + component_name: str, + dapr_component_envelope: _models.DaprComponent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a Managed Environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + environment_name: str, + component_name: str, + dapr_component_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + Creates or updates a Dapr Component in a Managed Environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -202,55 +282,74 @@ async def create_or_update( resource_group_name: str, environment_name: str, component_name: str, - dapr_component_envelope: "_models.DaprComponent", + dapr_component_envelope: Union[_models.DaprComponent, IO], **kwargs: Any - ) -> "_models.DaprComponent": + ) -> _models.DaprComponent: """Creates or updates a Dapr Component. Creates or updates a Dapr Component in a Managed Environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str - :param dapr_component_envelope: Configuration details of the Dapr Component. - :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent + :param dapr_component_envelope: Configuration details of the Dapr Component. Is either a model + type or a IO type. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DaprComponent, or the result of cls(response) + :return: DaprComponent or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.DaprComponent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprComponent"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] - _json = self._serialize.body(dapr_component_envelope, 'DaprComponent') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dapr_component_envelope, (IO, bytes)): + _content = dapr_component_envelope + else: + _json = self._serialize.body(dapr_component_envelope, "DaprComponent") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -258,64 +357,66 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DaprComponent', pipeline_response) + deserialized = self._deserialize("DaprComponent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, component_name: str, **kwargs: Any ) -> None: """Delete a Dapr Component. Delete a Dapr Component from a Managed Environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -326,57 +427,59 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore @distributed_trace_async async def list_secrets( - self, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any - ) -> "_models.DaprSecretsCollection": + self, resource_group_name: str, environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprSecretsCollection: """List secrets for a dapr component. List secrets for a dapr component. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DaprSecretsCollection, or the result of cls(response) + :return: DaprSecretsCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.DaprSecretsCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprSecretsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprSecretsCollection] - request = build_list_secrets_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_secrets.metadata['url'], + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -384,12 +487,11 @@ async def list_secrets( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DaprSecretsCollection', pipeline_response) + deserialized = self._deserialize("DaprSecretsCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}/listSecrets"} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}/listSecrets"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environment_diagnostics_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environment_diagnostics_operations.py new file mode 100644 index 0000000000000..d392dc357c2e8 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environment_diagnostics_operations.py @@ -0,0 +1,185 @@ +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._managed_environment_diagnostics_operations import ( + build_get_detector_request, + build_list_detectors_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ManagedEnvironmentDiagnosticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`managed_environment_diagnostics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def list_detectors( + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> _models.DiagnosticsCollection: + """Get the list of diagnostics for a given Managed Environment. + + Get the list of diagnostics for a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticsCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DiagnosticsCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticsCollection] + + request = build_list_detectors_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_detectors.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticsCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_detectors.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectors"} # type: ignore + + @distributed_trace_async + async def get_detector( + self, resource_group_name: str, environment_name: str, detector_name: str, **kwargs: Any + ) -> _models.Diagnostics: + """Get the diagnostics data for a given Managed Environment. + + Get the diagnostics data for a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param detector_name: Name of the Managed Environment detector. Required. + :type detector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Diagnostics or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Diagnostics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Diagnostics] + + request = build_get_detector_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + detector_name=detector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_detector.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Diagnostics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_detector.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectors/{detectorName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_diagnostics_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_diagnostics_operations.py new file mode 100644 index 0000000000000..cde345f82e39d --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_diagnostics_operations.py @@ -0,0 +1,115 @@ +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._managed_environments_diagnostics_operations import build_get_root_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ManagedEnvironmentsDiagnosticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`managed_environments_diagnostics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get_root( + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> _models.ManagedEnvironment: + """Get the properties of a Managed Environment. + + Get the properties of a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedEnvironment or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] + + request = build_get_root_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_root.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectorProperties/rootApi/"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_operations.py index 04589e9efe70b..23eb28bd9ab53 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_operations.py @@ -6,90 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._managed_environments_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request_initial -T = TypeVar('T') +from ...operations._managed_environments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_auth_token_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ManagedEnvironmentsOperations: - """ManagedEnvironmentsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagedEnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`managed_environments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ManagedEnvironmentsCollection"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ManagedEnvironment"]: """Get all Environments for a subscription. Get all Managed Environments for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedEnvironmentsCollection or the result of - cls(response) + :return: An iterator like instance of either ManagedEnvironment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironmentsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentsCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -103,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,60 +135,63 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.App/managedEnvironments"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/managedEnvironments"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ManagedEnvironmentsCollection"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ManagedEnvironment"]: """Get all the Environments in a resource group. Get all the Managed Environments in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedEnvironmentsCollection or the result of - cls(response) + :return: An iterator like instance of either ManagedEnvironment or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironmentsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentsCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -184,10 +205,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -198,56 +217,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> "_models.ManagedEnvironment": + async def get(self, resource_group_name: str, environment_name: str, **kwargs: Any) -> _models.ManagedEnvironment: """Get the properties of a Managed Environment. Get the properties of a Managed Environment used to host container apps. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironment, or the result of cls(response) + :return: ManagedEnvironment or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,89 +274,183 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any - ) -> "_models.ManagedEnvironment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironment"] + ) -> _models.ManagedEnvironment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(environment_envelope, 'ManagedEnvironment') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(environment_envelope, (IO, bytes)): + _content = environment_envelope + else: + _json = self._serialize.body(environment_envelope, "ManagedEnvironment") + + request = build_create_or_update_request( resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: _models.ManagedEnvironment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedEnvironment]: + """Creates or updates a Managed Environment. + + Creates or updates a Managed Environment used to host container apps. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ManagedEnvironment or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ManagedEnvironment]: + """Creates or updates a Managed Environment. + + Creates or updates a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ManagedEnvironment or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ManagedEnvironment"]: + ) -> AsyncLROPoller[_models.ManagedEnvironment]: """Creates or updates a Managed Environment. Creates or updates a Managed Environment used to host container apps. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param environment_envelope: Configuration details of the Environment. - :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :param environment_envelope: Configuration details of the Environment. Is either a model type + or a IO type. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -349,107 +462,111 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either ManagedEnvironment or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.appcontainers.models.ManagedEnvironment] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, environment_name=environment_name, environment_envelope=environment_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore @distributed_trace_async - async def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any + async def begin_delete( + self, resource_group_name: str, environment_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a Managed Environment. Delete a Managed Environment if it does not have any container apps. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -461,98 +578,190 @@ async def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, environment_name=environment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore async def _update_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(environment_envelope, 'ManagedEnvironment') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(environment_envelope, (IO, bytes)): + _content = environment_envelope + else: + _json = self._serialize.body(environment_envelope, "ManagedEnvironment") + + request = build_update_request( resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + + @overload + async def begin_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: _models.ManagedEnvironment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update Managed Environment's properties. + + Patches a Managed Environment using JSON Merge Patch. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Update Managed Environment's properties. + + Patches a Managed Environment using JSON Merge Patch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_update( # pylint: disable=inconsistent-return-statements + async def begin_update( self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any ) -> AsyncLROPoller[None]: """Update Managed Environment's properties. @@ -560,11 +769,16 @@ async def begin_update( # pylint: disable=inconsistent-return-statements Patches a Managed Environment using JSON Merge Patch. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param environment_envelope: Configuration details of the Environment. - :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :param environment_envelope: Configuration details of the Environment. Is either a model type + or a IO type. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for @@ -575,44 +789,112 @@ async def begin_update( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, environment_name=environment_name, environment_envelope=environment_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + + @distributed_trace_async + async def get_auth_token( + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> _models.EnvironmentAuthToken: + """Get auth token for a managed environment. + + Checks if resource name is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EnvironmentAuthToken or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.EnvironmentAuthToken + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentAuthToken] + + request = build_get_auth_token_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_auth_token.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EnvironmentAuthToken", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_auth_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/getAuthtoken"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_storages_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_storages_operations.py index 5a62d101684a0..5be2614126188 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_storages_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_managed_environments_storages_operations.py @@ -6,87 +6,103 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._managed_environments_storages_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._managed_environments_storages_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class ManagedEnvironmentsStoragesOperations: - """ManagedEnvironmentsStoragesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class ManagedEnvironmentsStoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`managed_environments_storages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def list( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> "_models.ManagedEnvironmentStoragesCollection": + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> _models.ManagedEnvironmentStoragesCollection: """Get all storages for a managedEnvironment. Get all storages for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironmentStoragesCollection, or the result of cls(response) + :return: ManagedEnvironmentStoragesCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStoragesCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentStoragesCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentStoragesCollection] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,64 +110,66 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironmentStoragesCollection', pipeline_response) + deserialized = self._deserialize("ManagedEnvironmentStoragesCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - environment_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.ManagedEnvironmentStorage": + self, resource_group_name: str, environment_name: str, storage_name: str, **kwargs: Any + ) -> _models.ManagedEnvironmentStorage: """Get storage for a managedEnvironment. Get storage for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param storage_name: Name of the storage. + :param storage_name: Name of the storage. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironmentStorage, or the result of cls(response) + :return: ManagedEnvironmentStorage or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentStorage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentStorage] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, storage_name=storage_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -159,15 +177,80 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironmentStorage', pipeline_response) + deserialized = self._deserialize("ManagedEnvironmentStorage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + environment_name: str, + storage_name: str, + storage_envelope: _models.ManagedEnvironmentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedEnvironmentStorage: + """Create or update storage for a managedEnvironment. + + Create or update storage for a managedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + environment_name: str, + storage_name: str, + storage_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedEnvironmentStorage: + """Create or update storage for a managedEnvironment. + Create or update storage for a managedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -175,55 +258,74 @@ async def create_or_update( resource_group_name: str, environment_name: str, storage_name: str, - storage_envelope: "_models.ManagedEnvironmentStorage", + storage_envelope: Union[_models.ManagedEnvironmentStorage, IO], **kwargs: Any - ) -> "_models.ManagedEnvironmentStorage": + ) -> _models.ManagedEnvironmentStorage: """Create or update storage for a managedEnvironment. Create or update storage for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param storage_name: Name of the storage. + :param storage_name: Name of the storage. Required. :type storage_name: str - :param storage_envelope: Configuration details of storage. - :type storage_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :param storage_envelope: Configuration details of storage. Is either a model type or a IO type. + Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironmentStorage, or the result of cls(response) + :return: ManagedEnvironmentStorage or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentStorage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(storage_envelope, 'ManagedEnvironmentStorage') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentStorage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_envelope, (IO, bytes)): + _content = storage_envelope + else: + _json = self._serialize.body(storage_envelope, "ManagedEnvironmentStorage") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, storage_name=storage_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -231,64 +333,66 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironmentStorage', pipeline_response) + deserialized = self._deserialize("ManagedEnvironmentStorage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, storage_name: str, **kwargs: Any ) -> None: """Delete storage for a managedEnvironment. Delete storage for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param storage_name: Name of the storage. + :param storage_name: Name of the storage. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, storage_name=storage_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -299,5 +403,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_namespaces_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_namespaces_operations.py index bf9e9706e7bcf..e33552674ac1b 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_namespaces_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_namespaces_operations.py @@ -6,95 +6,182 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._namespaces_operations import build_check_name_availability_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class NamespacesOperations: - """NamespacesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class NamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`namespaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( self, resource_group_name: str, environment_name: str, - check_name_availability_request: "_models.CheckNameAvailabilityRequest", + check_name_availability_request: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + ) -> _models.CheckNameAvailabilityResponse: """Checks the resource name availability. Checks if resource name is available. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param check_name_availability_request: The check name availability request. + :param check_name_availability_request: The check name availability request. Required. :type check_name_availability_request: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponse, or the result of cls(response) + :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, + resource_group_name: str, + environment_name: str, + check_name_availability_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource name availability. + + Checks if resource name is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param check_name_availability_request: The check name availability request. Required. + :type check_name_availability_request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, + resource_group_name: str, + environment_name: str, + check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource name availability. + + Checks if resource name is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param check_name_availability_request: The check name availability request. Is either a model + type or a IO type. Required. + :type check_name_availability_request: + ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_request, (IO, bytes)): + _content = check_name_availability_request + else: + _json = self._serialize.body(check_name_availability_request, "CheckNameAvailabilityRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,12 +189,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/checkNameAvailability"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_operations.py index a2773cdaf1ab4..f755d32945980 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_operations.py @@ -7,81 +7,95 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.aio.ContainerAppsAPIClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AvailableOperations"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.OperationDetail"]: """Lists all of the available RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailableOperations or the result of cls(response) + :return: An iterator like instance of either OperationDetail or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.appcontainers.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableOperations"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -95,10 +109,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -109,8 +121,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.App/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.App/operations"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_patch.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/__init__.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/__init__.py index 1948f779e92c3..2f13d39b12210 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/__init__.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/__init__.py @@ -24,6 +24,10 @@ from ._models_py3 import AzureFileProperties from ._models_py3 import AzureStaticWebApps from ._models_py3 import AzureStaticWebAppsRegistration +from ._models_py3 import BaseContainer +from ._models_py3 import BillingMeter +from ._models_py3 import BillingMeterCollection +from ._models_py3 import BillingMeterProperties from ._models_py3 import Certificate from ._models_py3 import CertificateCollection from ._models_py3 import CertificatePatch @@ -32,8 +36,14 @@ from ._models_py3 import CheckNameAvailabilityResponse from ._models_py3 import ClientRegistration from ._models_py3 import Configuration +from ._models_py3 import ConnectedEnvironment +from ._models_py3 import ConnectedEnvironmentCollection +from ._models_py3 import ConnectedEnvironmentStorage +from ._models_py3 import ConnectedEnvironmentStorageProperties +from ._models_py3 import ConnectedEnvironmentStoragesCollection from ._models_py3 import Container from ._models_py3 import ContainerApp +from ._models_py3 import ContainerAppAuthToken from ._models_py3 import ContainerAppCollection from ._models_py3 import ContainerAppProbe from ._models_py3 import ContainerAppProbeHttpGet @@ -43,7 +53,10 @@ from ._models_py3 import ContainerResources from ._models_py3 import CookieExpiration from ._models_py3 import CustomDomain +from ._models_py3 import CustomDomainConfiguration from ._models_py3 import CustomHostnameAnalysisResult +from ._models_py3 import CustomHostnameAnalysisResultCustomDomainVerificationFailureInfo +from ._models_py3 import CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsItem from ._models_py3 import CustomOpenIdConnectProvider from ._models_py3 import CustomScaleRule from ._models_py3 import Dapr @@ -55,7 +68,22 @@ from ._models_py3 import DefaultErrorResponse from ._models_py3 import DefaultErrorResponseError from ._models_py3 import DefaultErrorResponseErrorDetailsItem +from ._models_py3 import DiagnosticDataProviderMetadata +from ._models_py3 import DiagnosticDataProviderMetadataPropertyBagItem +from ._models_py3 import DiagnosticDataTableResponseColumn +from ._models_py3 import DiagnosticDataTableResponseObject +from ._models_py3 import DiagnosticRendering +from ._models_py3 import DiagnosticSupportTopic +from ._models_py3 import Diagnostics +from ._models_py3 import DiagnosticsCollection +from ._models_py3 import DiagnosticsDataApiResponse +from ._models_py3 import DiagnosticsDefinition +from ._models_py3 import DiagnosticsProperties +from ._models_py3 import DiagnosticsStatus +from ._models_py3 import EnvironmentAuthToken +from ._models_py3 import EnvironmentSkuProperties from ._models_py3 import EnvironmentVar +from ._models_py3 import ExtendedLocation from ._models_py3 import Facebook from ._models_py3 import ForwardProxy from ._models_py3 import GitHub @@ -67,12 +95,15 @@ from ._models_py3 import HttpSettingsRoutes from ._models_py3 import IdentityProviders from ._models_py3 import Ingress +from ._models_py3 import InitContainer +from ._models_py3 import IpSecurityRestrictionRule from ._models_py3 import JwtClaimChecks from ._models_py3 import LogAnalyticsConfiguration from ._models_py3 import Login from ._models_py3 import LoginRoutes from ._models_py3 import LoginScopes from ._models_py3 import ManagedEnvironment +from ._models_py3 import ManagedEnvironmentOutboundSettings from ._models_py3 import ManagedEnvironmentStorage from ._models_py3 import ManagedEnvironmentStorageProperties from ._models_py3 import ManagedEnvironmentStoragesCollection @@ -103,6 +134,7 @@ from ._models_py3 import SourceControl from ._models_py3 import SourceControlCollection from ._models_py3 import SystemData +from ._models_py3 import TcpScaleRule from ._models_py3 import Template from ._models_py3 import TrackedResource from ._models_py3 import TrafficWeight @@ -112,158 +144,208 @@ from ._models_py3 import VnetConfiguration from ._models_py3 import Volume from ._models_py3 import VolumeMount +from ._models_py3 import WorkloadProfile - -from ._container_apps_api_client_enums import ( - AccessMode, - ActiveRevisionsMode, - AppProtocol, - BindingType, - CertificateProvisioningState, - CheckNameAvailabilityReason, - ContainerAppProvisioningState, - CookieExpirationConvention, - CreatedByType, - DnsVerificationTestResult, - EnvironmentProvisioningState, - ForwardProxyConvention, - IngressTransportMethod, - ManagedServiceIdentityType, - RevisionHealthState, - RevisionProvisioningState, - Scheme, - SourceControlOperationState, - StorageType, - Type, - UnauthenticatedClientActionV2, -) +from ._container_apps_api_client_enums import AccessMode +from ._container_apps_api_client_enums import Action +from ._container_apps_api_client_enums import ActiveRevisionsMode +from ._container_apps_api_client_enums import AppProtocol +from ._container_apps_api_client_enums import BindingType +from ._container_apps_api_client_enums import Category +from ._container_apps_api_client_enums import CertificateProvisioningState +from ._container_apps_api_client_enums import CheckNameAvailabilityReason +from ._container_apps_api_client_enums import ConnectedEnvironmentProvisioningState +from ._container_apps_api_client_enums import ContainerAppProvisioningState +from ._container_apps_api_client_enums import CookieExpirationConvention +from ._container_apps_api_client_enums import CreatedByType +from ._container_apps_api_client_enums import DnsVerificationTestResult +from ._container_apps_api_client_enums import EnvironmentProvisioningState +from ._container_apps_api_client_enums import ExtendedLocationTypes +from ._container_apps_api_client_enums import ForwardProxyConvention +from ._container_apps_api_client_enums import IngressTransportMethod +from ._container_apps_api_client_enums import LogLevel +from ._container_apps_api_client_enums import ManagedEnvironmentOutBoundType +from ._container_apps_api_client_enums import ManagedServiceIdentityType +from ._container_apps_api_client_enums import RevisionHealthState +from ._container_apps_api_client_enums import RevisionProvisioningState +from ._container_apps_api_client_enums import Scheme +from ._container_apps_api_client_enums import SkuName +from ._container_apps_api_client_enums import SourceControlOperationState +from ._container_apps_api_client_enums import StorageType +from ._container_apps_api_client_enums import Type +from ._container_apps_api_client_enums import UnauthenticatedClientActionV2 +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AllowedAudiencesValidation', - 'AllowedPrincipals', - 'AppLogsConfiguration', - 'AppRegistration', - 'Apple', - 'AppleRegistration', - 'AuthConfig', - 'AuthConfigCollection', - 'AuthPlatform', - 'AvailableOperations', - 'AzureActiveDirectory', - 'AzureActiveDirectoryLogin', - 'AzureActiveDirectoryRegistration', - 'AzureActiveDirectoryValidation', - 'AzureCredentials', - 'AzureFileProperties', - 'AzureStaticWebApps', - 'AzureStaticWebAppsRegistration', - 'Certificate', - 'CertificateCollection', - 'CertificatePatch', - 'CertificateProperties', - 'CheckNameAvailabilityRequest', - 'CheckNameAvailabilityResponse', - 'ClientRegistration', - 'Configuration', - 'Container', - 'ContainerApp', - 'ContainerAppCollection', - 'ContainerAppProbe', - 'ContainerAppProbeHttpGet', - 'ContainerAppProbeHttpGetHttpHeadersItem', - 'ContainerAppProbeTcpSocket', - 'ContainerAppSecret', - 'ContainerResources', - 'CookieExpiration', - 'CustomDomain', - 'CustomHostnameAnalysisResult', - 'CustomOpenIdConnectProvider', - 'CustomScaleRule', - 'Dapr', - 'DaprComponent', - 'DaprComponentsCollection', - 'DaprMetadata', - 'DaprSecretsCollection', - 'DefaultAuthorizationPolicy', - 'DefaultErrorResponse', - 'DefaultErrorResponseError', - 'DefaultErrorResponseErrorDetailsItem', - 'EnvironmentVar', - 'Facebook', - 'ForwardProxy', - 'GitHub', - 'GithubActionConfiguration', - 'GlobalValidation', - 'Google', - 'HttpScaleRule', - 'HttpSettings', - 'HttpSettingsRoutes', - 'IdentityProviders', - 'Ingress', - 'JwtClaimChecks', - 'LogAnalyticsConfiguration', - 'Login', - 'LoginRoutes', - 'LoginScopes', - 'ManagedEnvironment', - 'ManagedEnvironmentStorage', - 'ManagedEnvironmentStorageProperties', - 'ManagedEnvironmentStoragesCollection', - 'ManagedEnvironmentsCollection', - 'ManagedServiceIdentity', - 'Nonce', - 'OpenIdConnectClientCredential', - 'OpenIdConnectConfig', - 'OpenIdConnectLogin', - 'OpenIdConnectRegistration', - 'OperationDetail', - 'OperationDisplay', - 'ProxyResource', - 'QueueScaleRule', - 'RegistryCredentials', - 'RegistryInfo', - 'Replica', - 'ReplicaCollection', - 'ReplicaContainer', - 'Resource', - 'Revision', - 'RevisionCollection', - 'Scale', - 'ScaleRule', - 'ScaleRuleAuth', - 'Secret', - 'SecretsCollection', - 'SourceControl', - 'SourceControlCollection', - 'SystemData', - 'Template', - 'TrackedResource', - 'TrafficWeight', - 'Twitter', - 'TwitterRegistration', - 'UserAssignedIdentity', - 'VnetConfiguration', - 'Volume', - 'VolumeMount', - 'AccessMode', - 'ActiveRevisionsMode', - 'AppProtocol', - 'BindingType', - 'CertificateProvisioningState', - 'CheckNameAvailabilityReason', - 'ContainerAppProvisioningState', - 'CookieExpirationConvention', - 'CreatedByType', - 'DnsVerificationTestResult', - 'EnvironmentProvisioningState', - 'ForwardProxyConvention', - 'IngressTransportMethod', - 'ManagedServiceIdentityType', - 'RevisionHealthState', - 'RevisionProvisioningState', - 'Scheme', - 'SourceControlOperationState', - 'StorageType', - 'Type', - 'UnauthenticatedClientActionV2', + "AllowedAudiencesValidation", + "AllowedPrincipals", + "AppLogsConfiguration", + "AppRegistration", + "Apple", + "AppleRegistration", + "AuthConfig", + "AuthConfigCollection", + "AuthPlatform", + "AvailableOperations", + "AzureActiveDirectory", + "AzureActiveDirectoryLogin", + "AzureActiveDirectoryRegistration", + "AzureActiveDirectoryValidation", + "AzureCredentials", + "AzureFileProperties", + "AzureStaticWebApps", + "AzureStaticWebAppsRegistration", + "BaseContainer", + "BillingMeter", + "BillingMeterCollection", + "BillingMeterProperties", + "Certificate", + "CertificateCollection", + "CertificatePatch", + "CertificateProperties", + "CheckNameAvailabilityRequest", + "CheckNameAvailabilityResponse", + "ClientRegistration", + "Configuration", + "ConnectedEnvironment", + "ConnectedEnvironmentCollection", + "ConnectedEnvironmentStorage", + "ConnectedEnvironmentStorageProperties", + "ConnectedEnvironmentStoragesCollection", + "Container", + "ContainerApp", + "ContainerAppAuthToken", + "ContainerAppCollection", + "ContainerAppProbe", + "ContainerAppProbeHttpGet", + "ContainerAppProbeHttpGetHttpHeadersItem", + "ContainerAppProbeTcpSocket", + "ContainerAppSecret", + "ContainerResources", + "CookieExpiration", + "CustomDomain", + "CustomDomainConfiguration", + "CustomHostnameAnalysisResult", + "CustomHostnameAnalysisResultCustomDomainVerificationFailureInfo", + "CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsItem", + "CustomOpenIdConnectProvider", + "CustomScaleRule", + "Dapr", + "DaprComponent", + "DaprComponentsCollection", + "DaprMetadata", + "DaprSecretsCollection", + "DefaultAuthorizationPolicy", + "DefaultErrorResponse", + "DefaultErrorResponseError", + "DefaultErrorResponseErrorDetailsItem", + "DiagnosticDataProviderMetadata", + "DiagnosticDataProviderMetadataPropertyBagItem", + "DiagnosticDataTableResponseColumn", + "DiagnosticDataTableResponseObject", + "DiagnosticRendering", + "DiagnosticSupportTopic", + "Diagnostics", + "DiagnosticsCollection", + "DiagnosticsDataApiResponse", + "DiagnosticsDefinition", + "DiagnosticsProperties", + "DiagnosticsStatus", + "EnvironmentAuthToken", + "EnvironmentSkuProperties", + "EnvironmentVar", + "ExtendedLocation", + "Facebook", + "ForwardProxy", + "GitHub", + "GithubActionConfiguration", + "GlobalValidation", + "Google", + "HttpScaleRule", + "HttpSettings", + "HttpSettingsRoutes", + "IdentityProviders", + "Ingress", + "InitContainer", + "IpSecurityRestrictionRule", + "JwtClaimChecks", + "LogAnalyticsConfiguration", + "Login", + "LoginRoutes", + "LoginScopes", + "ManagedEnvironment", + "ManagedEnvironmentOutboundSettings", + "ManagedEnvironmentStorage", + "ManagedEnvironmentStorageProperties", + "ManagedEnvironmentStoragesCollection", + "ManagedEnvironmentsCollection", + "ManagedServiceIdentity", + "Nonce", + "OpenIdConnectClientCredential", + "OpenIdConnectConfig", + "OpenIdConnectLogin", + "OpenIdConnectRegistration", + "OperationDetail", + "OperationDisplay", + "ProxyResource", + "QueueScaleRule", + "RegistryCredentials", + "RegistryInfo", + "Replica", + "ReplicaCollection", + "ReplicaContainer", + "Resource", + "Revision", + "RevisionCollection", + "Scale", + "ScaleRule", + "ScaleRuleAuth", + "Secret", + "SecretsCollection", + "SourceControl", + "SourceControlCollection", + "SystemData", + "TcpScaleRule", + "Template", + "TrackedResource", + "TrafficWeight", + "Twitter", + "TwitterRegistration", + "UserAssignedIdentity", + "VnetConfiguration", + "Volume", + "VolumeMount", + "WorkloadProfile", + "AccessMode", + "Action", + "ActiveRevisionsMode", + "AppProtocol", + "BindingType", + "Category", + "CertificateProvisioningState", + "CheckNameAvailabilityReason", + "ConnectedEnvironmentProvisioningState", + "ContainerAppProvisioningState", + "CookieExpirationConvention", + "CreatedByType", + "DnsVerificationTestResult", + "EnvironmentProvisioningState", + "ExtendedLocationTypes", + "ForwardProxyConvention", + "IngressTransportMethod", + "LogLevel", + "ManagedEnvironmentOutBoundType", + "ManagedServiceIdentityType", + "RevisionHealthState", + "RevisionProvisioningState", + "Scheme", + "SkuName", + "SourceControlOperationState", + "StorageType", + "Type", + "UnauthenticatedClientActionV2", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_container_apps_api_client_enums.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_container_apps_api_client_enums.py index 942689302057e..24c11a4132490 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_container_apps_api_client_enums.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_container_apps_api_client_enums.py @@ -7,49 +7,66 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Access mode for storage - """ +class AccessMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access mode for storage.""" READ_ONLY = "ReadOnly" READ_WRITE = "ReadWrite" -class ActiveRevisionsMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Action(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allow or Deny rules to determine for incoming IP. Note: Rules can only consist of ALL Allow or + ALL Deny. + """ + + ALLOW = "Allow" + DENY = "Deny" + + +class ActiveRevisionsMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ActiveRevisionsMode controls how active revisions are handled for the Container app: - - + + .. raw:: html - + Multiple: multiple revisions can be active.Single: Only one revision can be active at a time. Revision weights can not be used in this mode. If no value if - provided, this is the default. + provided, this is the default.. """ MULTIPLE = "Multiple" SINGLE = "Single" -class AppProtocol(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class AppProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Tells Dapr which protocol your application is using. Valid options are http and grpc. Default - is http + is http. """ HTTP = "http" GRPC = "grpc" -class BindingType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Custom Domain binding type. - """ + +class BindingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Custom Domain binding type.""" DISABLED = "Disabled" SNI_ENABLED = "SniEnabled" -class CertificateProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the certificate. - """ + +class Category(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Used to map workload profile types to billing meter.""" + + PREMIUM_SKU_GENERAL_PURPOSE = "PremiumSkuGeneralPurpose" + PREMIUM_SKU_MEMORY_OPTIMIZED = "PremiumSkuMemoryOptimized" + PREMIUM_SKU_COMPUTE_OPTIMIZED = "PremiumSkuComputeOptimized" + + +class CertificateProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the certificate.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -57,49 +74,63 @@ class CertificateProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, DELETE_FAILED = "DeleteFailed" PENDING = "Pending" -class CheckNameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason why the given name is not available. - """ + +class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason why the given name is not available.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class ContainerAppProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Container App. - """ + +class ConnectedEnvironmentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Kubernetes Environment.""" + + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + WAITING = "Waiting" + INITIALIZATION_IN_PROGRESS = "InitializationInProgress" + INFRASTRUCTURE_SETUP_IN_PROGRESS = "InfrastructureSetupInProgress" + INFRASTRUCTURE_SETUP_COMPLETE = "InfrastructureSetupComplete" + SCHEDULED_FOR_DELETE = "ScheduledForDelete" + + +class ContainerAppProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Container App.""" IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" CANCELED = "Canceled" + DELETING = "Deleting" -class CookieExpirationConvention(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The convention used when determining the session cookie's expiration. - """ + +class CookieExpirationConvention(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The convention used when determining the session cookie's expiration.""" FIXED_TIME = "FixedTime" IDENTITY_PROVIDER_DERIVED = "IdentityProviderDerived" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class DnsVerificationTestResult(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """DNS verification test result. - """ + +class DnsVerificationTestResult(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DNS verification test result.""" PASSED = "Passed" FAILED = "Failed" SKIPPED = "Skipped" -class EnvironmentProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the Environment. - """ + +class EnvironmentProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the Environment.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -112,23 +143,49 @@ class EnvironmentProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, UPGRADE_REQUESTED = "UpgradeRequested" UPGRADE_FAILED = "UpgradeFailed" -class ForwardProxyConvention(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The convention used to determine the url of the request made. - """ + +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of extendedLocation.""" + + CUSTOM_LOCATION = "CustomLocation" + + +class ForwardProxyConvention(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The convention used to determine the url of the request made.""" NO_PROXY = "NoProxy" STANDARD = "Standard" CUSTOM = "Custom" -class IngressTransportMethod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Ingress transport protocol - """ + +class IngressTransportMethod(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Ingress transport protocol.""" AUTO = "auto" HTTP = "http" HTTP2 = "http2" + TCP = "tcp" + + +class LogLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sets the log level for the Dapr sidecar. Allowed values are debug, info, warn, error. Default + is info. + """ + + INFO = "info" + DEBUG = "debug" + WARN = "warn" + ERROR = "error" + + +class ManagedEnvironmentOutBoundType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Outbound type for the cluster.""" + + LOAD_BALANCER = "LoadBalancer" + USER_DEFINED_ROUTING = "UserDefinedRouting" -class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ManagedServiceIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). """ @@ -138,17 +195,17 @@ class ManagedServiceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, En USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" -class RevisionHealthState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Current health State of the revision - """ + +class RevisionHealthState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current health State of the revision.""" HEALTHY = "Healthy" UNHEALTHY = "Unhealthy" NONE = "None" -class RevisionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Current provisioning State of the revision - """ + +class RevisionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current provisioning State of the revision.""" PROVISIONING = "Provisioning" PROVISIONED = "Provisioned" @@ -156,40 +213,49 @@ class RevisionProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enu DEPROVISIONING = "Deprovisioning" DEPROVISIONED = "Deprovisioned" -class Scheme(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Scheme to use for connecting to the host. Defaults to HTTP. - """ + +class Scheme(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Scheme to use for connecting to the host. Defaults to HTTP.""" HTTP = "HTTP" HTTPS = "HTTPS" -class SourceControlOperationState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Current provisioning State of the operation - """ + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of the Sku.""" + + #: Consumption SKU of Managed Environment. + CONSUMPTION = "Consumption" + #: Premium SKU of Managed Environment. + PREMIUM = "Premium" + + +class SourceControlOperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current provisioning State of the operation.""" IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" CANCELED = "Canceled" -class StorageType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Storage type for the volume. If not provided, use EmptyDir. - """ + +class StorageType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Storage type for the volume. If not provided, use EmptyDir.""" AZURE_FILE = "AzureFile" EMPTY_DIR = "EmptyDir" -class Type(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of probe. - """ + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of probe.""" LIVENESS = "Liveness" READINESS = "Readiness" STARTUP = "Startup" -class UnauthenticatedClientActionV2(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The action to take when an unauthenticated client attempts to access the app. - """ + +class UnauthenticatedClientActionV2(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The action to take when an unauthenticated client attempts to access the app.""" REDIRECT_TO_LOGIN_PAGE = "RedirectToLoginPage" ALLOW_ANONYMOUS = "AllowAnonymous" diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_models_py3.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_models_py3.py index 0767b061c0d25..4f315438aa183 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_models_py3.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,22 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._container_apps_api_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AllowedAudiencesValidation(msrest.serialization.Model): +class AllowedAudiencesValidation(_serialization.Model): """The configuration settings of the Allowed Audiences validation flow. :ivar allowed_audiences: The configuration settings of the allowed list of audiences from which @@ -24,25 +32,20 @@ class AllowedAudiencesValidation(msrest.serialization.Model): """ _attribute_map = { - 'allowed_audiences': {'key': 'allowedAudiences', 'type': '[str]'}, + "allowed_audiences": {"key": "allowedAudiences", "type": "[str]"}, } - def __init__( - self, - *, - allowed_audiences: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, allowed_audiences: Optional[List[str]] = None, **kwargs): """ :keyword allowed_audiences: The configuration settings of the allowed list of audiences from which to validate the JWT token. :paramtype allowed_audiences: list[str] """ - super(AllowedAudiencesValidation, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_audiences = allowed_audiences -class AllowedPrincipals(msrest.serialization.Model): +class AllowedPrincipals(_serialization.Model): """The configuration settings of the Azure Active Directory allowed principals. :ivar groups: The list of the allowed groups. @@ -52,29 +55,23 @@ class AllowedPrincipals(msrest.serialization.Model): """ _attribute_map = { - 'groups': {'key': 'groups', 'type': '[str]'}, - 'identities': {'key': 'identities', 'type': '[str]'}, + "groups": {"key": "groups", "type": "[str]"}, + "identities": {"key": "identities", "type": "[str]"}, } - def __init__( - self, - *, - groups: Optional[List[str]] = None, - identities: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, groups: Optional[List[str]] = None, identities: Optional[List[str]] = None, **kwargs): """ :keyword groups: The list of the allowed groups. :paramtype groups: list[str] :keyword identities: The list of the allowed identities. :paramtype identities: list[str] """ - super(AllowedPrincipals, self).__init__(**kwargs) + super().__init__(**kwargs) self.groups = groups self.identities = identities -class Apple(msrest.serialization.Model): +class Apple(_serialization.Model): """The configuration settings of the Apple provider. :ivar enabled: :code:`false` if the Apple provider should not be enabled despite @@ -87,17 +84,17 @@ class Apple(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'AppleRegistration'}, - 'login': {'key': 'login', 'type': 'LoginScopes'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "AppleRegistration"}, + "login": {"key": "login", "type": "LoginScopes"}, } def __init__( self, *, enabled: Optional[bool] = None, - registration: Optional["AppleRegistration"] = None, - login: Optional["LoginScopes"] = None, + registration: Optional["_models.AppleRegistration"] = None, + login: Optional["_models.LoginScopes"] = None, **kwargs ): """ @@ -109,13 +106,13 @@ def __init__( :keyword login: The configuration settings of the login flow. :paramtype login: ~azure.mgmt.appcontainers.models.LoginScopes """ - super(Apple, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration self.login = login -class AppleRegistration(msrest.serialization.Model): +class AppleRegistration(_serialization.Model): """The configuration settings of the registration for the Apple provider. :ivar client_id: The Client ID of the app used for login. @@ -125,29 +122,23 @@ class AppleRegistration(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret_setting_name': {'key': 'clientSecretSettingName', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret_setting_name": {"key": "clientSecretSettingName", "type": "str"}, } - def __init__( - self, - *, - client_id: Optional[str] = None, - client_secret_setting_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, client_id: Optional[str] = None, client_secret_setting_name: Optional[str] = None, **kwargs): """ :keyword client_id: The Client ID of the app used for login. :paramtype client_id: str :keyword client_secret_setting_name: The app setting name that contains the client secret. :paramtype client_secret_setting_name: str """ - super(AppleRegistration, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.client_secret_setting_name = client_secret_setting_name -class AppLogsConfiguration(msrest.serialization.Model): +class AppLogsConfiguration(_serialization.Model): """Configuration of application logs. :ivar destination: Logs destination. @@ -158,15 +149,15 @@ class AppLogsConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'destination': {'key': 'destination', 'type': 'str'}, - 'log_analytics_configuration': {'key': 'logAnalyticsConfiguration', 'type': 'LogAnalyticsConfiguration'}, + "destination": {"key": "destination", "type": "str"}, + "log_analytics_configuration": {"key": "logAnalyticsConfiguration", "type": "LogAnalyticsConfiguration"}, } def __init__( self, *, destination: Optional[str] = None, - log_analytics_configuration: Optional["LogAnalyticsConfiguration"] = None, + log_analytics_configuration: Optional["_models.LogAnalyticsConfiguration"] = None, **kwargs ): """ @@ -176,12 +167,12 @@ def __init__( :paramtype log_analytics_configuration: ~azure.mgmt.appcontainers.models.LogAnalyticsConfiguration """ - super(AppLogsConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.destination = destination self.log_analytics_configuration = log_analytics_configuration -class AppRegistration(msrest.serialization.Model): +class AppRegistration(_serialization.Model): """The configuration settings of the app registration for providers that have app ids and app secrets. :ivar app_id: The App ID of the app used for login. @@ -191,29 +182,23 @@ class AppRegistration(msrest.serialization.Model): """ _attribute_map = { - 'app_id': {'key': 'appId', 'type': 'str'}, - 'app_secret_setting_name': {'key': 'appSecretSettingName', 'type': 'str'}, + "app_id": {"key": "appId", "type": "str"}, + "app_secret_setting_name": {"key": "appSecretSettingName", "type": "str"}, } - def __init__( - self, - *, - app_id: Optional[str] = None, - app_secret_setting_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, app_id: Optional[str] = None, app_secret_setting_name: Optional[str] = None, **kwargs): """ :keyword app_id: The App ID of the app used for login. :paramtype app_id: str :keyword app_secret_setting_name: The app setting name that contains the app secret. :paramtype app_secret_setting_name: str """ - super(AppRegistration, self).__init__(**kwargs) + super().__init__(**kwargs) self.app_id = app_id self.app_secret_setting_name = app_secret_setting_name -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -232,26 +217,22 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -277,26 +258,22 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class AuthConfig(ProxyResource): @@ -333,32 +310,32 @@ class AuthConfig(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'platform': {'key': 'properties.platform', 'type': 'AuthPlatform'}, - 'global_validation': {'key': 'properties.globalValidation', 'type': 'GlobalValidation'}, - 'identity_providers': {'key': 'properties.identityProviders', 'type': 'IdentityProviders'}, - 'login': {'key': 'properties.login', 'type': 'Login'}, - 'http_settings': {'key': 'properties.httpSettings', 'type': 'HttpSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "platform": {"key": "properties.platform", "type": "AuthPlatform"}, + "global_validation": {"key": "properties.globalValidation", "type": "GlobalValidation"}, + "identity_providers": {"key": "properties.identityProviders", "type": "IdentityProviders"}, + "login": {"key": "properties.login", "type": "Login"}, + "http_settings": {"key": "properties.httpSettings", "type": "HttpSettings"}, } def __init__( self, *, - platform: Optional["AuthPlatform"] = None, - global_validation: Optional["GlobalValidation"] = None, - identity_providers: Optional["IdentityProviders"] = None, - login: Optional["Login"] = None, - http_settings: Optional["HttpSettings"] = None, + platform: Optional["_models.AuthPlatform"] = None, + global_validation: Optional["_models.GlobalValidation"] = None, + identity_providers: Optional["_models.IdentityProviders"] = None, + login: Optional["_models.Login"] = None, + http_settings: Optional["_models.HttpSettings"] = None, **kwargs ): """ @@ -378,7 +355,7 @@ def __init__( authorization requests made against ContainerApp Service Authentication/Authorization. :paramtype http_settings: ~azure.mgmt.appcontainers.models.HttpSettings """ - super(AuthConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.platform = platform self.global_validation = global_validation self.identity_providers = identity_providers @@ -386,45 +363,40 @@ def __init__( self.http_settings = http_settings -class AuthConfigCollection(msrest.serialization.Model): +class AuthConfigCollection(_serialization.Model): """AuthConfig collection ARM resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.AuthConfig] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[AuthConfig]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[AuthConfig]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["AuthConfig"], - **kwargs - ): + def __init__(self, *, value: List["_models.AuthConfig"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.AuthConfig] """ - super(AuthConfigCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class AuthPlatform(msrest.serialization.Model): +class AuthPlatform(_serialization.Model): """The configuration settings of the platform of ContainerApp Service Authentication/Authorization. :ivar enabled: :code:`true` if the Authentication / Authorization feature is @@ -438,17 +410,11 @@ class AuthPlatform(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - runtime_version: Optional[str] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, runtime_version: Optional[str] = None, **kwargs): """ :keyword enabled: :code:`true` if the Authentication / Authorization feature is enabled for the current app; otherwise, :code:`false`. @@ -459,12 +425,12 @@ def __init__( Authorization module. :paramtype runtime_version: str """ - super(AuthPlatform, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.runtime_version = runtime_version -class AvailableOperations(msrest.serialization.Model): +class AvailableOperations(_serialization.Model): """Available operations of the service. :ivar value: Collection of available operation details. @@ -475,16 +441,12 @@ class AvailableOperations(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[OperationDetail]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[OperationDetail]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["OperationDetail"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.OperationDetail"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: Collection of available operation details. @@ -493,12 +455,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(AvailableOperations, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class AzureActiveDirectory(msrest.serialization.Model): +class AzureActiveDirectory(_serialization.Model): """The configuration settings of the Azure Active directory provider. :ivar enabled: :code:`false` if the Azure Active Directory provider should not be @@ -520,20 +482,20 @@ class AzureActiveDirectory(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'AzureActiveDirectoryRegistration'}, - 'login': {'key': 'login', 'type': 'AzureActiveDirectoryLogin'}, - 'validation': {'key': 'validation', 'type': 'AzureActiveDirectoryValidation'}, - 'is_auto_provisioned': {'key': 'isAutoProvisioned', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "AzureActiveDirectoryRegistration"}, + "login": {"key": "login", "type": "AzureActiveDirectoryLogin"}, + "validation": {"key": "validation", "type": "AzureActiveDirectoryValidation"}, + "is_auto_provisioned": {"key": "isAutoProvisioned", "type": "bool"}, } def __init__( self, *, enabled: Optional[bool] = None, - registration: Optional["AzureActiveDirectoryRegistration"] = None, - login: Optional["AzureActiveDirectoryLogin"] = None, - validation: Optional["AzureActiveDirectoryValidation"] = None, + registration: Optional["_models.AzureActiveDirectoryRegistration"] = None, + login: Optional["_models.AzureActiveDirectoryLogin"] = None, + validation: Optional["_models.AzureActiveDirectoryValidation"] = None, is_auto_provisioned: Optional[bool] = None, **kwargs ): @@ -556,7 +518,7 @@ def __init__( read or write to this property. :paramtype is_auto_provisioned: bool """ - super(AzureActiveDirectory, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration self.login = login @@ -564,7 +526,7 @@ def __init__( self.is_auto_provisioned = is_auto_provisioned -class AzureActiveDirectoryLogin(msrest.serialization.Model): +class AzureActiveDirectoryLogin(_serialization.Model): """The configuration settings of the Azure Active Directory login flow. :ivar login_parameters: Login parameters to send to the OpenID Connect authorization endpoint @@ -577,16 +539,12 @@ class AzureActiveDirectoryLogin(msrest.serialization.Model): """ _attribute_map = { - 'login_parameters': {'key': 'loginParameters', 'type': '[str]'}, - 'disable_www_authenticate': {'key': 'disableWWWAuthenticate', 'type': 'bool'}, + "login_parameters": {"key": "loginParameters", "type": "[str]"}, + "disable_www_authenticate": {"key": "disableWWWAuthenticate", "type": "bool"}, } def __init__( - self, - *, - login_parameters: Optional[List[str]] = None, - disable_www_authenticate: Optional[bool] = None, - **kwargs + self, *, login_parameters: Optional[List[str]] = None, disable_www_authenticate: Optional[bool] = None, **kwargs ): """ :keyword login_parameters: Login parameters to send to the OpenID Connect authorization @@ -597,12 +555,12 @@ def __init__( should be omitted from the request; otherwise, :code:`false`. :paramtype disable_www_authenticate: bool """ - super(AzureActiveDirectoryLogin, self).__init__(**kwargs) + super().__init__(**kwargs) self.login_parameters = login_parameters self.disable_www_authenticate = disable_www_authenticate -class AzureActiveDirectoryRegistration(msrest.serialization.Model): +class AzureActiveDirectoryRegistration(_serialization.Model): """The configuration settings of the Azure Active Directory app registration. :ivar open_id_issuer: The OpenID Connect Issuer URI that represents the entity which issues @@ -638,12 +596,15 @@ class AzureActiveDirectoryRegistration(msrest.serialization.Model): """ _attribute_map = { - 'open_id_issuer': {'key': 'openIdIssuer', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret_setting_name': {'key': 'clientSecretSettingName', 'type': 'str'}, - 'client_secret_certificate_thumbprint': {'key': 'clientSecretCertificateThumbprint', 'type': 'str'}, - 'client_secret_certificate_subject_alternative_name': {'key': 'clientSecretCertificateSubjectAlternativeName', 'type': 'str'}, - 'client_secret_certificate_issuer': {'key': 'clientSecretCertificateIssuer', 'type': 'str'}, + "open_id_issuer": {"key": "openIdIssuer", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret_setting_name": {"key": "clientSecretSettingName", "type": "str"}, + "client_secret_certificate_thumbprint": {"key": "clientSecretCertificateThumbprint", "type": "str"}, + "client_secret_certificate_subject_alternative_name": { + "key": "clientSecretCertificateSubjectAlternativeName", + "type": "str", + }, + "client_secret_certificate_issuer": {"key": "clientSecretCertificateIssuer", "type": "str"}, } def __init__( @@ -689,7 +650,7 @@ def __init__( a replacement for the Client Secret Certificate Thumbprint. It is also optional. :paramtype client_secret_certificate_issuer: str """ - super(AzureActiveDirectoryRegistration, self).__init__(**kwargs) + super().__init__(**kwargs) self.open_id_issuer = open_id_issuer self.client_id = client_id self.client_secret_setting_name = client_secret_setting_name @@ -698,7 +659,7 @@ def __init__( self.client_secret_certificate_issuer = client_secret_certificate_issuer -class AzureActiveDirectoryValidation(msrest.serialization.Model): +class AzureActiveDirectoryValidation(_serialization.Model): """The configuration settings of the Azure Active Directory token validation flow. :ivar jwt_claim_checks: The configuration settings of the checks that should be made while @@ -714,17 +675,17 @@ class AzureActiveDirectoryValidation(msrest.serialization.Model): """ _attribute_map = { - 'jwt_claim_checks': {'key': 'jwtClaimChecks', 'type': 'JwtClaimChecks'}, - 'allowed_audiences': {'key': 'allowedAudiences', 'type': '[str]'}, - 'default_authorization_policy': {'key': 'defaultAuthorizationPolicy', 'type': 'DefaultAuthorizationPolicy'}, + "jwt_claim_checks": {"key": "jwtClaimChecks", "type": "JwtClaimChecks"}, + "allowed_audiences": {"key": "allowedAudiences", "type": "[str]"}, + "default_authorization_policy": {"key": "defaultAuthorizationPolicy", "type": "DefaultAuthorizationPolicy"}, } def __init__( self, *, - jwt_claim_checks: Optional["JwtClaimChecks"] = None, + jwt_claim_checks: Optional["_models.JwtClaimChecks"] = None, allowed_audiences: Optional[List[str]] = None, - default_authorization_policy: Optional["DefaultAuthorizationPolicy"] = None, + default_authorization_policy: Optional["_models.DefaultAuthorizationPolicy"] = None, **kwargs ): """ @@ -739,13 +700,13 @@ def __init__( :paramtype default_authorization_policy: ~azure.mgmt.appcontainers.models.DefaultAuthorizationPolicy """ - super(AzureActiveDirectoryValidation, self).__init__(**kwargs) + super().__init__(**kwargs) self.jwt_claim_checks = jwt_claim_checks self.allowed_audiences = allowed_audiences self.default_authorization_policy = default_authorization_policy -class AzureCredentials(msrest.serialization.Model): +class AzureCredentials(_serialization.Model): """Container App credentials. :ivar client_id: Client Id. @@ -759,10 +720,10 @@ class AzureCredentials(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret': {'key': 'clientSecret', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, } def __init__( @@ -784,31 +745,31 @@ def __init__( :keyword subscription_id: Subscription Id. :paramtype subscription_id: str """ - super(AzureCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.client_secret = client_secret self.tenant_id = tenant_id self.subscription_id = subscription_id -class AzureFileProperties(msrest.serialization.Model): +class AzureFileProperties(_serialization.Model): """Azure File Properties. :ivar account_name: Storage account name for azure file. :vartype account_name: str :ivar account_key: Storage account key for azure file. :vartype account_key: str - :ivar access_mode: Access mode for storage. Possible values include: "ReadOnly", "ReadWrite". + :ivar access_mode: Access mode for storage. Known values are: "ReadOnly" and "ReadWrite". :vartype access_mode: str or ~azure.mgmt.appcontainers.models.AccessMode :ivar share_name: Azure file share name. :vartype share_name: str """ _attribute_map = { - 'account_name': {'key': 'accountName', 'type': 'str'}, - 'account_key': {'key': 'accountKey', 'type': 'str'}, - 'access_mode': {'key': 'accessMode', 'type': 'str'}, - 'share_name': {'key': 'shareName', 'type': 'str'}, + "account_name": {"key": "accountName", "type": "str"}, + "account_key": {"key": "accountKey", "type": "str"}, + "access_mode": {"key": "accessMode", "type": "str"}, + "share_name": {"key": "shareName", "type": "str"}, } def __init__( @@ -816,7 +777,7 @@ def __init__( *, account_name: Optional[str] = None, account_key: Optional[str] = None, - access_mode: Optional[Union[str, "AccessMode"]] = None, + access_mode: Optional[Union[str, "_models.AccessMode"]] = None, share_name: Optional[str] = None, **kwargs ): @@ -825,20 +786,19 @@ def __init__( :paramtype account_name: str :keyword account_key: Storage account key for azure file. :paramtype account_key: str - :keyword access_mode: Access mode for storage. Possible values include: "ReadOnly", - "ReadWrite". + :keyword access_mode: Access mode for storage. Known values are: "ReadOnly" and "ReadWrite". :paramtype access_mode: str or ~azure.mgmt.appcontainers.models.AccessMode :keyword share_name: Azure file share name. :paramtype share_name: str """ - super(AzureFileProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.account_name = account_name self.account_key = account_key self.access_mode = access_mode self.share_name = share_name -class AzureStaticWebApps(msrest.serialization.Model): +class AzureStaticWebApps(_serialization.Model): """The configuration settings of the Azure Static Web Apps provider. :ivar enabled: :code:`false` if the Azure Static Web Apps provider should not be @@ -849,15 +809,15 @@ class AzureStaticWebApps(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'AzureStaticWebAppsRegistration'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "AzureStaticWebAppsRegistration"}, } def __init__( self, *, enabled: Optional[bool] = None, - registration: Optional["AzureStaticWebAppsRegistration"] = None, + registration: Optional["_models.AzureStaticWebAppsRegistration"] = None, **kwargs ): """ @@ -867,12 +827,12 @@ def __init__( :keyword registration: The configuration settings of the Azure Static Web Apps registration. :paramtype registration: ~azure.mgmt.appcontainers.models.AzureStaticWebAppsRegistration """ - super(AzureStaticWebApps, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration -class AzureStaticWebAppsRegistration(msrest.serialization.Model): +class AzureStaticWebAppsRegistration(_serialization.Model): """The configuration settings of the registration for the Azure Static Web Apps provider. :ivar client_id: The Client ID of the app used for login. @@ -880,30 +840,90 @@ class AzureStaticWebAppsRegistration(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, *, client_id: Optional[str] = None, **kwargs): + """ + :keyword client_id: The Client ID of the app used for login. + :paramtype client_id: str + """ + super().__init__(**kwargs) + self.client_id = client_id + + +class BaseContainer(_serialization.Model): + """Container App base container definition. + + :ivar image: Container image tag. + :vartype image: str + :ivar name: Custom container name. + :vartype name: str + :ivar command: Container start command. + :vartype command: list[str] + :ivar args: Container start command arguments. + :vartype args: list[str] + :ivar env: Container environment variables. + :vartype env: list[~azure.mgmt.appcontainers.models.EnvironmentVar] + :ivar resources: Container resource requirements. + :vartype resources: ~azure.mgmt.appcontainers.models.ContainerResources + :ivar volume_mounts: Container volume mounts. + :vartype volume_mounts: list[~azure.mgmt.appcontainers.models.VolumeMount] + """ + + _attribute_map = { + "image": {"key": "image", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "env": {"key": "env", "type": "[EnvironmentVar]"}, + "resources": {"key": "resources", "type": "ContainerResources"}, + "volume_mounts": {"key": "volumeMounts", "type": "[VolumeMount]"}, } def __init__( self, *, - client_id: Optional[str] = None, + image: Optional[str] = None, + name: Optional[str] = None, + command: Optional[List[str]] = None, + args: Optional[List[str]] = None, + env: Optional[List["_models.EnvironmentVar"]] = None, + resources: Optional["_models.ContainerResources"] = None, + volume_mounts: Optional[List["_models.VolumeMount"]] = None, **kwargs ): """ - :keyword client_id: The Client ID of the app used for login. - :paramtype client_id: str + :keyword image: Container image tag. + :paramtype image: str + :keyword name: Custom container name. + :paramtype name: str + :keyword command: Container start command. + :paramtype command: list[str] + :keyword args: Container start command arguments. + :paramtype args: list[str] + :keyword env: Container environment variables. + :paramtype env: list[~azure.mgmt.appcontainers.models.EnvironmentVar] + :keyword resources: Container resource requirements. + :paramtype resources: ~azure.mgmt.appcontainers.models.ContainerResources + :keyword volume_mounts: Container volume mounts. + :paramtype volume_mounts: list[~azure.mgmt.appcontainers.models.VolumeMount] """ - super(AzureStaticWebAppsRegistration, self).__init__(**kwargs) - self.client_id = client_id + super().__init__(**kwargs) + self.image = image + self.name = name + self.command = command + self.args = args + self.env = env + self.resources = resources + self.volume_mounts = volume_mounts -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. +class BillingMeter(ProxyResource): + """A premium billing meter. Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. - :ivar id: Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. :vartype id: str @@ -915,43 +935,158 @@ class TrackedResource(Resource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData - :ivar tags: A set of tags. Resource tags. - :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: Region for the billing meter. :vartype location: str + :ivar properties: Revision resource specific properties. + :vartype properties: ~azure.mgmt.appcontainers.models.BillingMeterProperties + """ + + _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"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "BillingMeterProperties"}, + } + + def __init__( + self, *, location: Optional[str] = None, properties: Optional["_models.BillingMeterProperties"] = None, **kwargs + ): + """ + :keyword location: Region for the billing meter. + :paramtype location: str + :keyword properties: Revision resource specific properties. + :paramtype properties: ~azure.mgmt.appcontainers.models.BillingMeterProperties + """ + super().__init__(**kwargs) + self.location = location + self.properties = properties + + +class BillingMeterCollection(_serialization.Model): + """Collection of premium workload billing meters. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Collection of billing meters. Required. + :vartype value: list[~azure.mgmt.appcontainers.models.BillingMeter] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[BillingMeter]"}, } + def __init__(self, *, value: List["_models.BillingMeter"], **kwargs): + """ + :keyword value: Collection of billing meters. Required. + :paramtype value: list[~azure.mgmt.appcontainers.models.BillingMeter] + """ + super().__init__(**kwargs) + self.value = value + + +class BillingMeterProperties(_serialization.Model): + """Revision resource specific properties. + + :ivar category: Used to map workload profile types to billing meter. Known values are: + "PremiumSkuGeneralPurpose", "PremiumSkuMemoryOptimized", and "PremiumSkuComputeOptimized". + :vartype category: str or ~azure.mgmt.appcontainers.models.Category + :ivar meter_type: Billing meter type. + :vartype meter_type: str + :ivar display_name: The everyday name of the billing meter. + :vartype display_name: str + """ + _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "category": {"key": "category", "type": "str"}, + "meter_type": {"key": "meterType", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } def __init__( self, *, - location: str, - tags: Optional[Dict[str, str]] = None, + category: Optional[Union[str, "_models.Category"]] = None, + meter_type: Optional[str] = None, + display_name: Optional[str] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword category: Used to map workload profile types to billing meter. Known values are: + "PremiumSkuGeneralPurpose", "PremiumSkuMemoryOptimized", and "PremiumSkuComputeOptimized". + :paramtype category: str or ~azure.mgmt.appcontainers.models.Category + :keyword meter_type: Billing meter type. + :paramtype meter_type: str + :keyword display_name: The everyday name of the billing meter. + :paramtype display_name: str + """ + super().__init__(**kwargs) + self.category = category + self.meter_type = meter_type + self.display_name = display_name + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location @@ -974,30 +1109,30 @@ class Certificate(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar properties: Certificate resource specific properties. :vartype properties: ~azure.mgmt.appcontainers.models.CertificateProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "CertificateProperties"}, } def __init__( @@ -1005,99 +1140,91 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - properties: Optional["CertificateProperties"] = None, + properties: Optional["_models.CertificateProperties"] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword properties: Certificate resource specific properties. :paramtype properties: ~azure.mgmt.appcontainers.models.CertificateProperties """ - super(Certificate, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.properties = properties -class CertificateCollection(msrest.serialization.Model): +class CertificateCollection(_serialization.Model): """Collection of Certificates. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.Certificate] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Certificate]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Certificate]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["Certificate"], - **kwargs - ): + def __init__(self, *, value: List["_models.Certificate"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.Certificate] """ - super(CertificateCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class CertificatePatch(msrest.serialization.Model): +class CertificatePatch(_serialization.Model): """A certificate to update. - :ivar tags: A set of tags. Application-specific metadata in the form of key-value pairs. + :ivar tags: Application-specific metadata in the form of key-value pairs. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Application-specific metadata in the form of key-value pairs. + :keyword tags: Application-specific metadata in the form of key-value pairs. :paramtype tags: dict[str, str] """ - super(CertificatePatch, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes """Certificate resource specific properties. Variables are only populated by the server, and will be ignored when sending a request. - :ivar provisioning_state: Provisioning state of the certificate. Possible values include: - "Succeeded", "Failed", "Canceled", "DeleteFailed", "Pending". + :ivar provisioning_state: Provisioning state of the certificate. Known values are: "Succeeded", + "Failed", "Canceled", "DeleteFailed", and "Pending". :vartype provisioning_state: str or ~azure.mgmt.appcontainers.models.CertificateProvisioningState :ivar password: Certificate password. :vartype password: str :ivar subject_name: Subject name of the certificate. :vartype subject_name: str + :ivar subject_alternative_names: Subject alternative names the certificate applies to. + :vartype subject_alternative_names: list[str] :ivar value: PFX or PEM blob. - :vartype value: bytearray + :vartype value: bytes :ivar issuer: Certificate issuer. :vartype issuer: str :ivar issue_date: Certificate issue Date. @@ -1113,46 +1240,43 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'provisioning_state': {'readonly': True}, - 'subject_name': {'readonly': True}, - 'issuer': {'readonly': True}, - 'issue_date': {'readonly': True}, - 'expiration_date': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'valid': {'readonly': True}, - 'public_key_hash': {'readonly': True}, + "provisioning_state": {"readonly": True}, + "subject_name": {"readonly": True}, + "subject_alternative_names": {"readonly": True}, + "issuer": {"readonly": True}, + "issue_date": {"readonly": True}, + "expiration_date": {"readonly": True}, + "thumbprint": {"readonly": True}, + "valid": {"readonly": True}, + "public_key_hash": {"readonly": True}, } _attribute_map = { - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'password': {'key': 'password', 'type': 'str'}, - 'subject_name': {'key': 'subjectName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'bytearray'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'issue_date': {'key': 'issueDate', 'type': 'iso-8601'}, - 'expiration_date': {'key': 'expirationDate', 'type': 'iso-8601'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'valid': {'key': 'valid', 'type': 'bool'}, - 'public_key_hash': {'key': 'publicKeyHash', 'type': 'str'}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "password": {"key": "password", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + "subject_alternative_names": {"key": "subjectAlternativeNames", "type": "[str]"}, + "value": {"key": "value", "type": "bytearray"}, + "issuer": {"key": "issuer", "type": "str"}, + "issue_date": {"key": "issueDate", "type": "iso-8601"}, + "expiration_date": {"key": "expirationDate", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "valid": {"key": "valid", "type": "bool"}, + "public_key_hash": {"key": "publicKeyHash", "type": "str"}, } - def __init__( - self, - *, - password: Optional[str] = None, - value: Optional[bytearray] = None, - **kwargs - ): + def __init__(self, *, password: Optional[str] = None, value: Optional[bytes] = None, **kwargs): """ :keyword password: Certificate password. :paramtype password: str :keyword value: PFX or PEM blob. - :paramtype value: bytearray + :paramtype value: bytes """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.provisioning_state = None self.password = password self.subject_name = None + self.subject_alternative_names = None self.value = value self.issuer = None self.issue_date = None @@ -1162,7 +1286,7 @@ def __init__( self.public_key_hash = None -class CheckNameAvailabilityRequest(msrest.serialization.Model): +class CheckNameAvailabilityRequest(_serialization.Model): """The check availability request body. :ivar name: The name of the resource for which availability needs to be checked. @@ -1172,70 +1296,64 @@ class CheckNameAvailabilityRequest(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): """ :keyword name: The name of the resource for which availability needs to be checked. :paramtype name: str :keyword type: The resource type. :paramtype type: str """ - super(CheckNameAvailabilityRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class CheckNameAvailabilityResponse(msrest.serialization.Model): +class CheckNameAvailabilityResponse(_serialization.Model): """The check availability result. :ivar name_available: Indicates if the resource name is available. :vartype name_available: bool - :ivar reason: The reason why the given name is not available. Possible values include: - "Invalid", "AlreadyExists". + :ivar reason: The reason why the given name is not available. Known values are: "Invalid" and + "AlreadyExists". :vartype reason: str or ~azure.mgmt.appcontainers.models.CheckNameAvailabilityReason :ivar message: Detailed reason why the given name is available. :vartype message: str """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( self, *, name_available: Optional[bool] = None, - reason: Optional[Union[str, "CheckNameAvailabilityReason"]] = None, + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, message: Optional[str] = None, **kwargs ): """ :keyword name_available: Indicates if the resource name is available. :paramtype name_available: bool - :keyword reason: The reason why the given name is not available. Possible values include: - "Invalid", "AlreadyExists". + :keyword reason: The reason why the given name is not available. Known values are: "Invalid" + and "AlreadyExists". :paramtype reason: str or ~azure.mgmt.appcontainers.models.CheckNameAvailabilityReason :keyword message: Detailed reason why the given name is available. :paramtype message: str """ - super(CheckNameAvailabilityResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class ClientRegistration(msrest.serialization.Model): +class ClientRegistration(_serialization.Model): """The configuration settings of the app registration for providers that have client ids and client secrets. :ivar client_id: The Client ID of the app used for login. @@ -1245,42 +1363,36 @@ class ClientRegistration(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_secret_setting_name': {'key': 'clientSecretSettingName', 'type': 'str'}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret_setting_name": {"key": "clientSecretSettingName", "type": "str"}, } - def __init__( - self, - *, - client_id: Optional[str] = None, - client_secret_setting_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, client_id: Optional[str] = None, client_secret_setting_name: Optional[str] = None, **kwargs): """ :keyword client_id: The Client ID of the app used for login. :paramtype client_id: str :keyword client_secret_setting_name: The app setting name that contains the client secret. :paramtype client_secret_setting_name: str """ - super(ClientRegistration, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.client_secret_setting_name = client_secret_setting_name -class Configuration(msrest.serialization.Model): +class Configuration(_serialization.Model): """Non versioned Container App configuration properties that define the mutable settings of a Container app. :ivar secrets: Collection of secrets used by a Container app. :vartype secrets: list[~azure.mgmt.appcontainers.models.Secret] :ivar active_revisions_mode: ActiveRevisionsMode controls how active revisions are handled for the Container app: - - + + .. raw:: html - + Multiple: multiple revisions can be active.Single: Only one revision can be active at a time. Revision weights can not be used in this mode. If no value if - provided, this is the default.. Possible values include: "Multiple", "Single". + provided, this is the default.. Known values are: "Multiple" and "Single". :vartype active_revisions_mode: str or ~azure.mgmt.appcontainers.models.ActiveRevisionsMode :ivar ingress: Ingress configurations. :vartype ingress: ~azure.mgmt.appcontainers.models.Ingress @@ -1289,24 +1401,28 @@ class Configuration(msrest.serialization.Model): :vartype registries: list[~azure.mgmt.appcontainers.models.RegistryCredentials] :ivar dapr: Dapr configuration for the Container App. :vartype dapr: ~azure.mgmt.appcontainers.models.Dapr + :ivar max_inactive_revisions: Optional. Max inactive revisions a Container App can have. + :vartype max_inactive_revisions: int """ _attribute_map = { - 'secrets': {'key': 'secrets', 'type': '[Secret]'}, - 'active_revisions_mode': {'key': 'activeRevisionsMode', 'type': 'str'}, - 'ingress': {'key': 'ingress', 'type': 'Ingress'}, - 'registries': {'key': 'registries', 'type': '[RegistryCredentials]'}, - 'dapr': {'key': 'dapr', 'type': 'Dapr'}, + "secrets": {"key": "secrets", "type": "[Secret]"}, + "active_revisions_mode": {"key": "activeRevisionsMode", "type": "str"}, + "ingress": {"key": "ingress", "type": "Ingress"}, + "registries": {"key": "registries", "type": "[RegistryCredentials]"}, + "dapr": {"key": "dapr", "type": "Dapr"}, + "max_inactive_revisions": {"key": "maxInactiveRevisions", "type": "int"}, } def __init__( self, *, - secrets: Optional[List["Secret"]] = None, - active_revisions_mode: Optional[Union[str, "ActiveRevisionsMode"]] = None, - ingress: Optional["Ingress"] = None, - registries: Optional[List["RegistryCredentials"]] = None, - dapr: Optional["Dapr"] = None, + secrets: Optional[List["_models.Secret"]] = None, + active_revisions_mode: Optional[Union[str, "_models.ActiveRevisionsMode"]] = None, + ingress: Optional["_models.Ingress"] = None, + registries: Optional[List["_models.RegistryCredentials"]] = None, + dapr: Optional["_models.Dapr"] = None, + max_inactive_revisions: Optional[int] = None, **kwargs ): """ @@ -1314,13 +1430,13 @@ def __init__( :paramtype secrets: list[~azure.mgmt.appcontainers.models.Secret] :keyword active_revisions_mode: ActiveRevisionsMode controls how active revisions are handled for the Container app: - - + + .. raw:: html - + Multiple: multiple revisions can be active.Single: Only one revision can be active at a time. Revision weights can not be used in this mode. If no value if - provided, this is the default.. Possible values include: "Multiple", "Single". + provided, this is the default.. Known values are: "Multiple" and "Single". :paramtype active_revisions_mode: str or ~azure.mgmt.appcontainers.models.ActiveRevisionsMode :keyword ingress: Ingress configurations. :paramtype ingress: ~azure.mgmt.appcontainers.models.Ingress @@ -1329,90 +1445,325 @@ def __init__( :paramtype registries: list[~azure.mgmt.appcontainers.models.RegistryCredentials] :keyword dapr: Dapr configuration for the Container App. :paramtype dapr: ~azure.mgmt.appcontainers.models.Dapr + :keyword max_inactive_revisions: Optional. Max inactive revisions a Container App can have. + :paramtype max_inactive_revisions: int """ - super(Configuration, self).__init__(**kwargs) + super().__init__(**kwargs) self.secrets = secrets self.active_revisions_mode = active_revisions_mode self.ingress = ingress self.registries = registries self.dapr = dapr + self.max_inactive_revisions = max_inactive_revisions -class Container(msrest.serialization.Model): - """Container App container definition. +class ConnectedEnvironment(TrackedResource): # pylint: disable=too-many-instance-attributes + """An environment for Kubernetes cluster specialized for web workloads by Azure App Service. - :ivar image: Container image tag. - :vartype image: str - :ivar name: Custom container name. - :vartype name: str - :ivar command: Container start command. - :vartype command: list[str] - :ivar args: Container start command arguments. - :vartype args: list[str] - :ivar env: Container environment variables. - :vartype env: list[~azure.mgmt.appcontainers.models.EnvironmentVar] - :ivar resources: Container resource requirements. - :vartype resources: ~azure.mgmt.appcontainers.models.ContainerResources - :ivar probes: List of probes for the container. - :vartype probes: list[~azure.mgmt.appcontainers.models.ContainerAppProbe] - :ivar volume_mounts: Container volume mounts. - :vartype volume_mounts: list[~azure.mgmt.appcontainers.models.VolumeMount] - """ + Variables are only populated by the server, and will be ignored when sending a request. - _attribute_map = { - 'image': {'key': 'image', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'command': {'key': 'command', 'type': '[str]'}, - 'args': {'key': 'args', 'type': '[str]'}, - 'env': {'key': 'env', 'type': '[EnvironmentVar]'}, - 'resources': {'key': 'resources', 'type': 'ContainerResources'}, - 'probes': {'key': 'probes', 'type': '[ContainerAppProbe]'}, - 'volume_mounts': {'key': 'volumeMounts', 'type': '[VolumeMount]'}, - } + All required parameters must be populated in order to send to Azure. - def __init__( - self, - *, - image: Optional[str] = None, - name: Optional[str] = None, - command: Optional[List[str]] = None, - args: Optional[List[str]] = None, - env: Optional[List["EnvironmentVar"]] = None, - resources: Optional["ContainerResources"] = None, - probes: Optional[List["ContainerAppProbe"]] = None, - volume_mounts: Optional[List["VolumeMount"]] = None, - **kwargs - ): - """ - :keyword image: Container image tag. - :paramtype image: str - :keyword name: Custom container name. - :paramtype name: str - :keyword command: Container start command. - :paramtype command: list[str] - :keyword args: Container start command arguments. - :paramtype args: list[str] + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar extended_location: The complex type of the extended location. + :vartype extended_location: ~azure.mgmt.appcontainers.models.ExtendedLocation + :ivar provisioning_state: Provisioning state of the Kubernetes Environment. Known values are: + "Succeeded", "Failed", "Canceled", "Waiting", "InitializationInProgress", + "InfrastructureSetupInProgress", "InfrastructureSetupComplete", and "ScheduledForDelete". + :vartype provisioning_state: str or + ~azure.mgmt.appcontainers.models.ConnectedEnvironmentProvisioningState + :ivar deployment_errors: Any errors that occurred during deployment or deployment validation. + :vartype deployment_errors: str + :ivar default_domain: Default Domain Name for the cluster. + :vartype default_domain: str + :ivar static_ip: Static IP of the connectedEnvironment. + :vartype static_ip: str + :ivar dapr_ai_connection_string: Application Insights connection string used by Dapr to export + Service to Service communication telemetry. + :vartype dapr_ai_connection_string: str + :ivar custom_domain_configuration: Custom domain configuration for the environment. + :vartype custom_domain_configuration: + ~azure.mgmt.appcontainers.models.CustomDomainConfiguration + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "deployment_errors": {"readonly": True}, + "default_domain": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "deployment_errors": {"key": "properties.deploymentErrors", "type": "str"}, + "default_domain": {"key": "properties.defaultDomain", "type": "str"}, + "static_ip": {"key": "properties.staticIp", "type": "str"}, + "dapr_ai_connection_string": {"key": "properties.daprAIConnectionString", "type": "str"}, + "custom_domain_configuration": { + "key": "properties.customDomainConfiguration", + "type": "CustomDomainConfiguration", + }, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + static_ip: Optional[str] = None, + dapr_ai_connection_string: Optional[str] = None, + custom_domain_configuration: Optional["_models.CustomDomainConfiguration"] = None, + **kwargs + ): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword extended_location: The complex type of the extended location. + :paramtype extended_location: ~azure.mgmt.appcontainers.models.ExtendedLocation + :keyword static_ip: Static IP of the connectedEnvironment. + :paramtype static_ip: str + :keyword dapr_ai_connection_string: Application Insights connection string used by Dapr to + export Service to Service communication telemetry. + :paramtype dapr_ai_connection_string: str + :keyword custom_domain_configuration: Custom domain configuration for the environment. + :paramtype custom_domain_configuration: + ~azure.mgmt.appcontainers.models.CustomDomainConfiguration + """ + super().__init__(tags=tags, location=location, **kwargs) + self.extended_location = extended_location + self.provisioning_state = None + self.deployment_errors = None + self.default_domain = None + self.static_ip = static_ip + self.dapr_ai_connection_string = dapr_ai_connection_string + self.custom_domain_configuration = custom_domain_configuration + + +class ConnectedEnvironmentCollection(_serialization.Model): + """Collection of connectedEnvironments. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of resources. + :vartype value: list[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :ivar next_link: Link to next page of resources. + :vartype next_link: str + """ + + _validation = { + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ConnectedEnvironment]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: Optional[List["_models.ConnectedEnvironment"]] = None, **kwargs): + """ + :keyword value: Collection of resources. + :paramtype value: list[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class ConnectedEnvironmentStorage(ProxyResource): + """Storage resource for connectedEnvironment. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData + :ivar properties: Storage properties. + :vartype properties: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorageProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "ConnectedEnvironmentStorageProperties"}, + } + + def __init__(self, *, properties: Optional["_models.ConnectedEnvironmentStorageProperties"] = None, **kwargs): + """ + :keyword properties: Storage properties. + :paramtype properties: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorageProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ConnectedEnvironmentStorageProperties(_serialization.Model): + """Storage properties. + + :ivar azure_file: Azure file properties. + :vartype azure_file: ~azure.mgmt.appcontainers.models.AzureFileProperties + """ + + _attribute_map = { + "azure_file": {"key": "azureFile", "type": "AzureFileProperties"}, + } + + def __init__(self, *, azure_file: Optional["_models.AzureFileProperties"] = None, **kwargs): + """ + :keyword azure_file: Azure file properties. + :paramtype azure_file: ~azure.mgmt.appcontainers.models.AzureFileProperties + """ + super().__init__(**kwargs) + self.azure_file = azure_file + + +class ConnectedEnvironmentStoragesCollection(_serialization.Model): + """Collection of Storage for Environments. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Collection of storage resources. Required. + :vartype value: list[~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage] + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ConnectedEnvironmentStorage]"}, + } + + def __init__(self, *, value: List["_models.ConnectedEnvironmentStorage"], **kwargs): + """ + :keyword value: Collection of storage resources. Required. + :paramtype value: list[~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage] + """ + super().__init__(**kwargs) + self.value = value + + +class Container(BaseContainer): + """Container App container definition. + + :ivar image: Container image tag. + :vartype image: str + :ivar name: Custom container name. + :vartype name: str + :ivar command: Container start command. + :vartype command: list[str] + :ivar args: Container start command arguments. + :vartype args: list[str] + :ivar env: Container environment variables. + :vartype env: list[~azure.mgmt.appcontainers.models.EnvironmentVar] + :ivar resources: Container resource requirements. + :vartype resources: ~azure.mgmt.appcontainers.models.ContainerResources + :ivar volume_mounts: Container volume mounts. + :vartype volume_mounts: list[~azure.mgmt.appcontainers.models.VolumeMount] + :ivar probes: List of probes for the container. + :vartype probes: list[~azure.mgmt.appcontainers.models.ContainerAppProbe] + """ + + _attribute_map = { + "image": {"key": "image", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "env": {"key": "env", "type": "[EnvironmentVar]"}, + "resources": {"key": "resources", "type": "ContainerResources"}, + "volume_mounts": {"key": "volumeMounts", "type": "[VolumeMount]"}, + "probes": {"key": "probes", "type": "[ContainerAppProbe]"}, + } + + def __init__( + self, + *, + image: Optional[str] = None, + name: Optional[str] = None, + command: Optional[List[str]] = None, + args: Optional[List[str]] = None, + env: Optional[List["_models.EnvironmentVar"]] = None, + resources: Optional["_models.ContainerResources"] = None, + volume_mounts: Optional[List["_models.VolumeMount"]] = None, + probes: Optional[List["_models.ContainerAppProbe"]] = None, + **kwargs + ): + """ + :keyword image: Container image tag. + :paramtype image: str + :keyword name: Custom container name. + :paramtype name: str + :keyword command: Container start command. + :paramtype command: list[str] + :keyword args: Container start command arguments. + :paramtype args: list[str] :keyword env: Container environment variables. :paramtype env: list[~azure.mgmt.appcontainers.models.EnvironmentVar] :keyword resources: Container resource requirements. :paramtype resources: ~azure.mgmt.appcontainers.models.ContainerResources - :keyword probes: List of probes for the container. - :paramtype probes: list[~azure.mgmt.appcontainers.models.ContainerAppProbe] :keyword volume_mounts: Container volume mounts. :paramtype volume_mounts: list[~azure.mgmt.appcontainers.models.VolumeMount] + :keyword probes: List of probes for the container. + :paramtype probes: list[~azure.mgmt.appcontainers.models.ContainerAppProbe] """ - super(Container, self).__init__(**kwargs) - self.image = image - self.name = name - self.command = command - self.args = args - self.env = env - self.resources = resources + super().__init__( + image=image, + name=name, + command=command, + args=args, + env=env, + resources=resources, + volume_mounts=volume_mounts, + **kwargs + ) self.probes = probes - self.volume_mounts = volume_mounts -class ContainerApp(TrackedResource): +class ContainerApp(TrackedResource): # pylint: disable=too-many-instance-attributes """Container App. Variables are only populated by the server, and will be ignored when sending a request. @@ -1430,19 +1781,25 @@ class ContainerApp(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str + :ivar extended_location: The complex type of the extended location. + :vartype extended_location: ~azure.mgmt.appcontainers.models.ExtendedLocation :ivar identity: managed identities for the Container App to interact with other Azure services without maintaining any secrets or credentials in code. :vartype identity: ~azure.mgmt.appcontainers.models.ManagedServiceIdentity - :ivar provisioning_state: Provisioning state of the Container App. Possible values include: - "InProgress", "Succeeded", "Failed", "Canceled". + :ivar provisioning_state: Provisioning state of the Container App. Known values are: + "InProgress", "Succeeded", "Failed", "Canceled", and "Deleting". :vartype provisioning_state: str or ~azure.mgmt.appcontainers.models.ContainerAppProvisioningState - :ivar managed_environment_id: Resource ID of the Container App's environment. + :ivar managed_environment_id: Deprecated. Resource ID of the Container App's environment. :vartype managed_environment_id: str + :ivar environment_id: Resource ID of environment. + :vartype environment_id: str + :ivar workload_profile_type: Workload profile type to pin for container app execution. + :vartype workload_profile_type: str :ivar latest_revision_name: Name of the latest revision of the Container App. :vartype latest_revision_name: str :ivar latest_revision_fqdn: Fully Qualified Domain Name of the latest revision of the Container @@ -1456,37 +1813,44 @@ class ContainerApp(TrackedResource): :vartype template: ~azure.mgmt.appcontainers.models.Template :ivar outbound_ip_addresses: Outbound IP Addresses for container app. :vartype outbound_ip_addresses: list[str] + :ivar event_stream_endpoint: The endpoint of the eventstream of the container app. + :vartype event_stream_endpoint: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'latest_revision_name': {'readonly': True}, - 'latest_revision_fqdn': {'readonly': True}, - 'custom_domain_verification_id': {'readonly': True}, - 'outbound_ip_addresses': {'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'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'managed_environment_id': {'key': 'properties.managedEnvironmentId', 'type': 'str'}, - 'latest_revision_name': {'key': 'properties.latestRevisionName', 'type': 'str'}, - 'latest_revision_fqdn': {'key': 'properties.latestRevisionFqdn', 'type': 'str'}, - 'custom_domain_verification_id': {'key': 'properties.customDomainVerificationId', 'type': 'str'}, - 'configuration': {'key': 'properties.configuration', 'type': 'Configuration'}, - 'template': {'key': 'properties.template', 'type': 'Template'}, - 'outbound_ip_addresses': {'key': 'properties.outboundIPAddresses', 'type': '[str]'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "latest_revision_name": {"readonly": True}, + "latest_revision_fqdn": {"readonly": True}, + "custom_domain_verification_id": {"readonly": True}, + "outbound_ip_addresses": {"readonly": True}, + "event_stream_endpoint": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "managed_environment_id": {"key": "properties.managedEnvironmentId", "type": "str"}, + "environment_id": {"key": "properties.environmentId", "type": "str"}, + "workload_profile_type": {"key": "properties.workloadProfileType", "type": "str"}, + "latest_revision_name": {"key": "properties.latestRevisionName", "type": "str"}, + "latest_revision_fqdn": {"key": "properties.latestRevisionFqdn", "type": "str"}, + "custom_domain_verification_id": {"key": "properties.customDomainVerificationId", "type": "str"}, + "configuration": {"key": "properties.configuration", "type": "Configuration"}, + "template": {"key": "properties.template", "type": "Template"}, + "outbound_ip_addresses": {"key": "properties.outboundIPAddresses", "type": "[str]"}, + "event_stream_endpoint": {"key": "properties.eventStreamEndpoint", "type": "str"}, } def __init__( @@ -1494,78 +1858,147 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, - identity: Optional["ManagedServiceIdentity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + identity: Optional["_models.ManagedServiceIdentity"] = None, managed_environment_id: Optional[str] = None, - configuration: Optional["Configuration"] = None, - template: Optional["Template"] = None, + environment_id: Optional[str] = None, + workload_profile_type: Optional[str] = None, + configuration: Optional["_models.Configuration"] = None, + template: Optional["_models.Template"] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str + :keyword extended_location: The complex type of the extended location. + :paramtype extended_location: ~azure.mgmt.appcontainers.models.ExtendedLocation :keyword identity: managed identities for the Container App to interact with other Azure services without maintaining any secrets or credentials in code. :paramtype identity: ~azure.mgmt.appcontainers.models.ManagedServiceIdentity - :keyword managed_environment_id: Resource ID of the Container App's environment. + :keyword managed_environment_id: Deprecated. Resource ID of the Container App's environment. :paramtype managed_environment_id: str + :keyword environment_id: Resource ID of environment. + :paramtype environment_id: str + :keyword workload_profile_type: Workload profile type to pin for container app execution. + :paramtype workload_profile_type: str :keyword configuration: Non versioned Container App configuration properties. :paramtype configuration: ~azure.mgmt.appcontainers.models.Configuration :keyword template: Container App versioned application definition. :paramtype template: ~azure.mgmt.appcontainers.models.Template """ - super(ContainerApp, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) + self.extended_location = extended_location self.identity = identity self.provisioning_state = None self.managed_environment_id = managed_environment_id + self.environment_id = environment_id + self.workload_profile_type = workload_profile_type self.latest_revision_name = None self.latest_revision_fqdn = None self.custom_domain_verification_id = None self.configuration = configuration self.template = template self.outbound_ip_addresses = None + self.event_stream_endpoint = None + + +class ContainerAppAuthToken(TrackedResource): + """Container App Auth Token. + + Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar token: Auth token value. + :vartype token: str + :ivar expires: Token expiration date. + :vartype expires: ~datetime.datetime + """ -class ContainerAppCollection(msrest.serialization.Model): + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "token": {"readonly": True}, + "expires": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "token": {"key": "properties.token", "type": "str"}, + "expires": {"key": "properties.expires", "type": "iso-8601"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.token = None + self.expires = None + + +class ContainerAppCollection(_serialization.Model): """Container App collection ARM resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.ContainerApp] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ContainerApp]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ContainerApp]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["ContainerApp"], - **kwargs - ): + def __init__(self, *, value: List["_models.ContainerApp"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.ContainerApp] """ - super(ContainerAppCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class ContainerAppProbe(msrest.serialization.Model): +class ContainerAppProbe(_serialization.Model): """Probe describes a health check to be performed against a container to determine whether it is alive or ready to receive traffic. :ivar failure_threshold: Minimum consecutive failures for the probe to be considered failed @@ -1595,38 +2028,38 @@ class ContainerAppProbe(msrest.serialization.Model): The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. Maximum value is 3600 seconds (1 hour). - :vartype termination_grace_period_seconds: long + :vartype termination_grace_period_seconds: int :ivar timeout_seconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Maximum value is 240. :vartype timeout_seconds: int - :ivar type: The type of probe. Possible values include: "Liveness", "Readiness", "Startup". + :ivar type: The type of probe. Known values are: "Liveness", "Readiness", and "Startup". :vartype type: str or ~azure.mgmt.appcontainers.models.Type """ _attribute_map = { - 'failure_threshold': {'key': 'failureThreshold', 'type': 'int'}, - 'http_get': {'key': 'httpGet', 'type': 'ContainerAppProbeHttpGet'}, - 'initial_delay_seconds': {'key': 'initialDelaySeconds', 'type': 'int'}, - 'period_seconds': {'key': 'periodSeconds', 'type': 'int'}, - 'success_threshold': {'key': 'successThreshold', 'type': 'int'}, - 'tcp_socket': {'key': 'tcpSocket', 'type': 'ContainerAppProbeTcpSocket'}, - 'termination_grace_period_seconds': {'key': 'terminationGracePeriodSeconds', 'type': 'long'}, - 'timeout_seconds': {'key': 'timeoutSeconds', 'type': 'int'}, - 'type': {'key': 'type', 'type': 'str'}, + "failure_threshold": {"key": "failureThreshold", "type": "int"}, + "http_get": {"key": "httpGet", "type": "ContainerAppProbeHttpGet"}, + "initial_delay_seconds": {"key": "initialDelaySeconds", "type": "int"}, + "period_seconds": {"key": "periodSeconds", "type": "int"}, + "success_threshold": {"key": "successThreshold", "type": "int"}, + "tcp_socket": {"key": "tcpSocket", "type": "ContainerAppProbeTcpSocket"}, + "termination_grace_period_seconds": {"key": "terminationGracePeriodSeconds", "type": "int"}, + "timeout_seconds": {"key": "timeoutSeconds", "type": "int"}, + "type": {"key": "type", "type": "str"}, } def __init__( self, *, failure_threshold: Optional[int] = None, - http_get: Optional["ContainerAppProbeHttpGet"] = None, + http_get: Optional["_models.ContainerAppProbeHttpGet"] = None, initial_delay_seconds: Optional[int] = None, period_seconds: Optional[int] = None, success_threshold: Optional[int] = None, - tcp_socket: Optional["ContainerAppProbeTcpSocket"] = None, + tcp_socket: Optional["_models.ContainerAppProbeTcpSocket"] = None, termination_grace_period_seconds: Optional[int] = None, timeout_seconds: Optional[int] = None, - type: Optional[Union[str, "Type"]] = None, + type: Optional[Union[str, "_models.Type"]] = None, **kwargs ): """ @@ -1657,14 +2090,14 @@ def __init__( integer. The value zero indicates stop immediately via the kill signal (no opportunity to shut down). This is an alpha field and requires enabling ProbeTerminationGracePeriod feature gate. Maximum value is 3600 seconds (1 hour). - :paramtype termination_grace_period_seconds: long + :paramtype termination_grace_period_seconds: int :keyword timeout_seconds: Number of seconds after which the probe times out. Defaults to 1 second. Minimum value is 1. Maximum value is 240. :paramtype timeout_seconds: int - :keyword type: The type of probe. Possible values include: "Liveness", "Readiness", "Startup". + :keyword type: The type of probe. Known values are: "Liveness", "Readiness", and "Startup". :paramtype type: str or ~azure.mgmt.appcontainers.models.Type """ - super(ContainerAppProbe, self).__init__(**kwargs) + super().__init__(**kwargs) self.failure_threshold = failure_threshold self.http_get = http_get self.initial_delay_seconds = initial_delay_seconds @@ -1676,7 +2109,7 @@ def __init__( self.type = type -class ContainerAppProbeHttpGet(msrest.serialization.Model): +class ContainerAppProbeHttpGet(_serialization.Model): """HTTPGet specifies the http request to perform. All required parameters must be populated in order to send to Azure. @@ -1689,24 +2122,24 @@ class ContainerAppProbeHttpGet(msrest.serialization.Model): list[~azure.mgmt.appcontainers.models.ContainerAppProbeHttpGetHttpHeadersItem] :ivar path: Path to access on the HTTP server. :vartype path: str - :ivar port: Required. Name or number of the port to access on the container. Number must be in - the range 1 to 65535. Name must be an IANA_SVC_NAME. + :ivar port: Name or number of the port to access on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. Required. :vartype port: int - :ivar scheme: Scheme to use for connecting to the host. Defaults to HTTP. Possible values - include: "HTTP", "HTTPS". + :ivar scheme: Scheme to use for connecting to the host. Defaults to HTTP. Known values are: + "HTTP" and "HTTPS". :vartype scheme: str or ~azure.mgmt.appcontainers.models.Scheme """ _validation = { - 'port': {'required': True}, + "port": {"required": True}, } _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'http_headers': {'key': 'httpHeaders', 'type': '[ContainerAppProbeHttpGetHttpHeadersItem]'}, - 'path': {'key': 'path', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, - 'scheme': {'key': 'scheme', 'type': 'str'}, + "host": {"key": "host", "type": "str"}, + "http_headers": {"key": "httpHeaders", "type": "[ContainerAppProbeHttpGetHttpHeadersItem]"}, + "path": {"key": "path", "type": "str"}, + "port": {"key": "port", "type": "int"}, + "scheme": {"key": "scheme", "type": "str"}, } def __init__( @@ -1714,9 +2147,9 @@ def __init__( *, port: int, host: Optional[str] = None, - http_headers: Optional[List["ContainerAppProbeHttpGetHttpHeadersItem"]] = None, + http_headers: Optional[List["_models.ContainerAppProbeHttpGetHttpHeadersItem"]] = None, path: Optional[str] = None, - scheme: Optional[Union[str, "Scheme"]] = None, + scheme: Optional[Union[str, "_models.Scheme"]] = None, **kwargs ): """ @@ -1728,14 +2161,14 @@ def __init__( list[~azure.mgmt.appcontainers.models.ContainerAppProbeHttpGetHttpHeadersItem] :keyword path: Path to access on the HTTP server. :paramtype path: str - :keyword port: Required. Name or number of the port to access on the container. Number must be - in the range 1 to 65535. Name must be an IANA_SVC_NAME. + :keyword port: Name or number of the port to access on the container. Number must be in the + range 1 to 65535. Name must be an IANA_SVC_NAME. Required. :paramtype port: int - :keyword scheme: Scheme to use for connecting to the host. Defaults to HTTP. Possible values - include: "HTTP", "HTTPS". + :keyword scheme: Scheme to use for connecting to the host. Defaults to HTTP. Known values are: + "HTTP" and "HTTPS". :paramtype scheme: str or ~azure.mgmt.appcontainers.models.Scheme """ - super(ContainerAppProbeHttpGet, self).__init__(**kwargs) + super().__init__(**kwargs) self.host = host self.http_headers = http_headers self.path = path @@ -1743,86 +2176,74 @@ def __init__( self.scheme = scheme -class ContainerAppProbeHttpGetHttpHeadersItem(msrest.serialization.Model): +class ContainerAppProbeHttpGetHttpHeadersItem(_serialization.Model): """HTTPHeader describes a custom header to be used in HTTP probes. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The header field name. + :ivar name: The header field name. Required. :vartype name: str - :ivar value: Required. The header field value. + :ivar value: The header field value. Required. :vartype value: str """ _validation = { - 'name': {'required': True}, - 'value': {'required': True}, + "name": {"required": True}, + "value": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, value: str, **kwargs): """ - :keyword name: Required. The header field name. + :keyword name: The header field name. Required. :paramtype name: str - :keyword value: Required. The header field value. + :keyword value: The header field value. Required. :paramtype value: str """ - super(ContainerAppProbeHttpGetHttpHeadersItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class ContainerAppProbeTcpSocket(msrest.serialization.Model): +class ContainerAppProbeTcpSocket(_serialization.Model): """TCPSocket specifies an action involving a TCP port. TCP hooks not yet supported. All required parameters must be populated in order to send to Azure. :ivar host: Optional: Host name to connect to, defaults to the pod IP. :vartype host: str - :ivar port: Required. Number or name of the port to access on the container. Number must be in - the range 1 to 65535. Name must be an IANA_SVC_NAME. + :ivar port: Number or name of the port to access on the container. Number must be in the range + 1 to 65535. Name must be an IANA_SVC_NAME. Required. :vartype port: int """ _validation = { - 'port': {'required': True}, + "port": {"required": True}, } _attribute_map = { - 'host': {'key': 'host', 'type': 'str'}, - 'port': {'key': 'port', 'type': 'int'}, + "host": {"key": "host", "type": "str"}, + "port": {"key": "port", "type": "int"}, } - def __init__( - self, - *, - port: int, - host: Optional[str] = None, - **kwargs - ): + def __init__(self, *, port: int, host: Optional[str] = None, **kwargs): """ :keyword host: Optional: Host name to connect to, defaults to the pod IP. :paramtype host: str - :keyword port: Required. Number or name of the port to access on the container. Number must be - in the range 1 to 65535. Name must be an IANA_SVC_NAME. + :keyword port: Number or name of the port to access on the container. Number must be in the + range 1 to 65535. Name must be an IANA_SVC_NAME. Required. :paramtype port: int """ - super(ContainerAppProbeTcpSocket, self).__init__(**kwargs) + super().__init__(**kwargs) self.host = host self.port = port -class ContainerAppSecret(msrest.serialization.Model): +class ContainerAppSecret(_serialization.Model): """Container App Secret. Variables are only populated by the server, and will be ignored when sending a request. @@ -1834,27 +2255,23 @@ class ContainerAppSecret(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ContainerAppSecret, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class ContainerResources(msrest.serialization.Model): +class ContainerResources(_serialization.Model): """Container App container resource requirements. Variables are only populated by the server, and will be ignored when sending a request. @@ -1868,39 +2285,33 @@ class ContainerResources(msrest.serialization.Model): """ _validation = { - 'ephemeral_storage': {'readonly': True}, + "ephemeral_storage": {"readonly": True}, } _attribute_map = { - 'cpu': {'key': 'cpu', 'type': 'float'}, - 'memory': {'key': 'memory', 'type': 'str'}, - 'ephemeral_storage': {'key': 'ephemeralStorage', 'type': 'str'}, + "cpu": {"key": "cpu", "type": "float"}, + "memory": {"key": "memory", "type": "str"}, + "ephemeral_storage": {"key": "ephemeralStorage", "type": "str"}, } - def __init__( - self, - *, - cpu: Optional[float] = None, - memory: Optional[str] = None, - **kwargs - ): + def __init__(self, *, cpu: Optional[float] = None, memory: Optional[str] = None, **kwargs): """ :keyword cpu: Required CPU in cores, e.g. 0.5. :paramtype cpu: float :keyword memory: Required memory, e.g. "250Mb". :paramtype memory: str """ - super(ContainerResources, self).__init__(**kwargs) + super().__init__(**kwargs) self.cpu = cpu self.memory = memory self.ephemeral_storage = None -class CookieExpiration(msrest.serialization.Model): +class CookieExpiration(_serialization.Model): """The configuration settings of the session cookie's expiration. - :ivar convention: The convention used when determining the session cookie's expiration. - Possible values include: "FixedTime", "IdentityProviderDerived". + :ivar convention: The convention used when determining the session cookie's expiration. Known + values are: "FixedTime" and "IdentityProviderDerived". :vartype convention: str or ~azure.mgmt.appcontainers.models.CookieExpirationConvention :ivar time_to_expiration: The time after the request is made when the session cookie should expire. @@ -1908,54 +2319,53 @@ class CookieExpiration(msrest.serialization.Model): """ _attribute_map = { - 'convention': {'key': 'convention', 'type': 'str'}, - 'time_to_expiration': {'key': 'timeToExpiration', 'type': 'str'}, + "convention": {"key": "convention", "type": "str"}, + "time_to_expiration": {"key": "timeToExpiration", "type": "str"}, } def __init__( self, *, - convention: Optional[Union[str, "CookieExpirationConvention"]] = None, + convention: Optional[Union[str, "_models.CookieExpirationConvention"]] = None, time_to_expiration: Optional[str] = None, **kwargs ): """ :keyword convention: The convention used when determining the session cookie's expiration. - Possible values include: "FixedTime", "IdentityProviderDerived". + Known values are: "FixedTime" and "IdentityProviderDerived". :paramtype convention: str or ~azure.mgmt.appcontainers.models.CookieExpirationConvention :keyword time_to_expiration: The time after the request is made when the session cookie should expire. :paramtype time_to_expiration: str """ - super(CookieExpiration, self).__init__(**kwargs) + super().__init__(**kwargs) self.convention = convention self.time_to_expiration = time_to_expiration -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """Custom Domain of a Container App. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Hostname. + :ivar name: Hostname. Required. :vartype name: str - :ivar binding_type: Custom Domain binding type. Possible values include: "Disabled", - "SniEnabled". + :ivar binding_type: Custom Domain binding type. Known values are: "Disabled" and "SniEnabled". :vartype binding_type: str or ~azure.mgmt.appcontainers.models.BindingType - :ivar certificate_id: Required. Resource Id of the Certificate to be bound to this hostname. - Must exist in the Managed Environment. + :ivar certificate_id: Resource Id of the Certificate to be bound to this hostname. Must exist + in the Managed Environment. Required. :vartype certificate_id: str """ _validation = { - 'name': {'required': True}, - 'certificate_id': {'required': True}, + "name": {"required": True}, + "certificate_id": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'binding_type': {'key': 'bindingType', 'type': 'str'}, - 'certificate_id': {'key': 'certificateId', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "binding_type": {"key": "bindingType", "type": "str"}, + "certificate_id": {"key": "certificateId", "type": "str"}, } def __init__( @@ -1963,54 +2373,107 @@ def __init__( *, name: str, certificate_id: str, - binding_type: Optional[Union[str, "BindingType"]] = None, + binding_type: Optional[Union[str, "_models.BindingType"]] = None, **kwargs ): """ - :keyword name: Required. Hostname. + :keyword name: Hostname. Required. :paramtype name: str - :keyword binding_type: Custom Domain binding type. Possible values include: "Disabled", + :keyword binding_type: Custom Domain binding type. Known values are: "Disabled" and "SniEnabled". :paramtype binding_type: str or ~azure.mgmt.appcontainers.models.BindingType - :keyword certificate_id: Required. Resource Id of the Certificate to be bound to this hostname. - Must exist in the Managed Environment. + :keyword certificate_id: Resource Id of the Certificate to be bound to this hostname. Must + exist in the Managed Environment. Required. :paramtype certificate_id: str """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.binding_type = binding_type self.certificate_id = certificate_id -class CustomHostnameAnalysisResult(ProxyResource): - """Custom domain analysis. +class CustomDomainConfiguration(_serialization.Model): + """Configuration properties for apps environment custom domain. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar custom_domain_verification_id: Id used to verify domain name ownership. + :vartype custom_domain_verification_id: str + :ivar dns_suffix: Dns suffix for the environment domain. + :vartype dns_suffix: str + :ivar certificate_value: PFX or PEM blob. + :vartype certificate_value: bytes + :ivar certificate_password: Certificate password. + :vartype certificate_password: bytes + :ivar expiration_date: Certificate expiration date. + :vartype expiration_date: ~datetime.datetime + :ivar thumbprint: Certificate thumbprint. + :vartype thumbprint: str + :ivar subject_name: Subject name of the certificate. + :vartype subject_name: str + """ + + _validation = { + "custom_domain_verification_id": {"readonly": True}, + "expiration_date": {"readonly": True}, + "thumbprint": {"readonly": True}, + "subject_name": {"readonly": True}, + } + + _attribute_map = { + "custom_domain_verification_id": {"key": "customDomainVerificationId", "type": "str"}, + "dns_suffix": {"key": "dnsSuffix", "type": "str"}, + "certificate_value": {"key": "certificateValue", "type": "bytearray"}, + "certificate_password": {"key": "certificatePassword", "type": "bytearray"}, + "expiration_date": {"key": "expirationDate", "type": "iso-8601"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "subject_name": {"key": "subjectName", "type": "str"}, + } + + def __init__( + self, + *, + dns_suffix: Optional[str] = None, + certificate_value: Optional[bytes] = None, + certificate_password: Optional[bytes] = None, + **kwargs + ): + """ + :keyword dns_suffix: Dns suffix for the environment domain. + :paramtype dns_suffix: str + :keyword certificate_value: PFX or PEM blob. + :paramtype certificate_value: bytes + :keyword certificate_password: Certificate password. + :paramtype certificate_password: bytes + """ + super().__init__(**kwargs) + self.custom_domain_verification_id = None + self.dns_suffix = dns_suffix + self.certificate_value = certificate_value + self.certificate_password = certificate_password + self.expiration_date = None + self.thumbprint = None + self.subject_name = None + + +class CustomHostnameAnalysisResult(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Custom domain analysis. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData :ivar host_name: Host name that was analyzed. :vartype host_name: str :ivar is_hostname_already_verified: :code:`true` if hostname is already verified; otherwise, :code:`false`. :vartype is_hostname_already_verified: bool - :ivar custom_domain_verification_test: DNS verification test result. Possible values include: - "Passed", "Failed", "Skipped". + :ivar custom_domain_verification_test: DNS verification test result. Known values are: + "Passed", "Failed", and "Skipped". :vartype custom_domain_verification_test: str or ~azure.mgmt.appcontainers.models.DnsVerificationTestResult :ivar custom_domain_verification_failure_info: Raw failure information if DNS verification fails. :vartype custom_domain_verification_failure_info: - ~azure.mgmt.appcontainers.models.DefaultErrorResponse + ~azure.mgmt.appcontainers.models.CustomHostnameAnalysisResultCustomDomainVerificationFailureInfo :ivar has_conflict_on_managed_environment: :code:`true` if there is a conflict on the Container App's managed environment; otherwise, :code:`false`. :vartype has_conflict_on_managed_environment: bool @@ -2030,34 +2493,29 @@ class CustomHostnameAnalysisResult(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'host_name': {'readonly': True}, - 'is_hostname_already_verified': {'readonly': True}, - 'custom_domain_verification_test': {'readonly': True}, - 'custom_domain_verification_failure_info': {'readonly': True}, - 'has_conflict_on_managed_environment': {'readonly': True}, - 'conflicting_container_app_resource_id': {'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'}, - 'host_name': {'key': 'properties.hostName', 'type': 'str'}, - 'is_hostname_already_verified': {'key': 'properties.isHostnameAlreadyVerified', 'type': 'bool'}, - 'custom_domain_verification_test': {'key': 'properties.customDomainVerificationTest', 'type': 'str'}, - 'custom_domain_verification_failure_info': {'key': 'properties.customDomainVerificationFailureInfo', 'type': 'DefaultErrorResponse'}, - 'has_conflict_on_managed_environment': {'key': 'properties.hasConflictOnManagedEnvironment', 'type': 'bool'}, - 'conflicting_container_app_resource_id': {'key': 'properties.conflictingContainerAppResourceId', 'type': 'str'}, - 'c_name_records': {'key': 'properties.cNameRecords', 'type': '[str]'}, - 'txt_records': {'key': 'properties.txtRecords', 'type': '[str]'}, - 'a_records': {'key': 'properties.aRecords', 'type': '[str]'}, - 'alternate_c_name_records': {'key': 'properties.alternateCNameRecords', 'type': '[str]'}, - 'alternate_txt_records': {'key': 'properties.alternateTxtRecords', 'type': '[str]'}, + "host_name": {"readonly": True}, + "is_hostname_already_verified": {"readonly": True}, + "custom_domain_verification_test": {"readonly": True}, + "custom_domain_verification_failure_info": {"readonly": True}, + "has_conflict_on_managed_environment": {"readonly": True}, + "conflicting_container_app_resource_id": {"readonly": True}, + } + + _attribute_map = { + "host_name": {"key": "hostName", "type": "str"}, + "is_hostname_already_verified": {"key": "isHostnameAlreadyVerified", "type": "bool"}, + "custom_domain_verification_test": {"key": "customDomainVerificationTest", "type": "str"}, + "custom_domain_verification_failure_info": { + "key": "customDomainVerificationFailureInfo", + "type": "CustomHostnameAnalysisResultCustomDomainVerificationFailureInfo", + }, + "has_conflict_on_managed_environment": {"key": "hasConflictOnManagedEnvironment", "type": "bool"}, + "conflicting_container_app_resource_id": {"key": "conflictingContainerAppResourceId", "type": "str"}, + "c_name_records": {"key": "cNameRecords", "type": "[str]"}, + "txt_records": {"key": "txtRecords", "type": "[str]"}, + "a_records": {"key": "aRecords", "type": "[str]"}, + "alternate_c_name_records": {"key": "alternateCNameRecords", "type": "[str]"}, + "alternate_txt_records": {"key": "alternateTxtRecords", "type": "[str]"}, } def __init__( @@ -2082,7 +2540,7 @@ def __init__( :keyword alternate_txt_records: Alternate TXT records visible for this hostname. :paramtype alternate_txt_records: list[str] """ - super(CustomHostnameAnalysisResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.host_name = None self.is_hostname_already_verified = None self.custom_domain_verification_test = None @@ -2096,7 +2554,92 @@ def __init__( self.alternate_txt_records = alternate_txt_records -class CustomOpenIdConnectProvider(msrest.serialization.Model): +class CustomHostnameAnalysisResultCustomDomainVerificationFailureInfo(_serialization.Model): + """Raw failure information if DNS verification fails. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Standardized string to programmatically identify the error. + :vartype code: str + :ivar message: Detailed error description and debugging information. + :vartype message: str + :ivar target: Detailed error description and debugging information. + :vartype target: str + :ivar details: Details or the error. + :vartype details: + list[~azure.mgmt.appcontainers.models.CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsItem] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": { + "key": "details", + "type": "[CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsItem]", + }, + } + + def __init__( + self, + *, + details: Optional[ + List["_models.CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsItem"] + ] = None, + **kwargs + ): + """ + :keyword details: Details or the error. + :paramtype details: + list[~azure.mgmt.appcontainers.models.CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsItem] + """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = details + + +class CustomHostnameAnalysisResultCustomDomainVerificationFailureInfoDetailsItem(_serialization.Model): + """Detailed errors. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: Standardized string to programmatically identify the error. + :vartype code: str + :ivar message: Detailed error description and debugging information. + :vartype message: str + :ivar target: Detailed error description and debugging information. + :vartype target: str + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + + +class CustomOpenIdConnectProvider(_serialization.Model): """The configuration settings of the custom Open ID Connect provider. :ivar enabled: :code:`false` if the custom Open ID provider provider should not be @@ -2111,17 +2654,17 @@ class CustomOpenIdConnectProvider(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'OpenIdConnectRegistration'}, - 'login': {'key': 'login', 'type': 'OpenIdConnectLogin'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "OpenIdConnectRegistration"}, + "login": {"key": "login", "type": "OpenIdConnectLogin"}, } def __init__( self, *, enabled: Optional[bool] = None, - registration: Optional["OpenIdConnectRegistration"] = None, - login: Optional["OpenIdConnectLogin"] = None, + registration: Optional["_models.OpenIdConnectRegistration"] = None, + login: Optional["_models.OpenIdConnectLogin"] = None, **kwargs ): """ @@ -2135,13 +2678,13 @@ def __init__( provider. :paramtype login: ~azure.mgmt.appcontainers.models.OpenIdConnectLogin """ - super(CustomOpenIdConnectProvider, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration self.login = login -class CustomScaleRule(msrest.serialization.Model): +class CustomScaleRule(_serialization.Model): """Container App container Custom scaling rule. :ivar type: Type of the custom scale rule @@ -2154,9 +2697,9 @@ class CustomScaleRule(msrest.serialization.Model): """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'metadata', 'type': '{str}'}, - 'auth': {'key': 'auth', 'type': '[ScaleRuleAuth]'}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "metadata", "type": "{str}"}, + "auth": {"key": "auth", "type": "[ScaleRuleAuth]"}, } def __init__( @@ -2164,7 +2707,7 @@ def __init__( *, type: Optional[str] = None, metadata: Optional[Dict[str, str]] = None, - auth: Optional[List["ScaleRuleAuth"]] = None, + auth: Optional[List["_models.ScaleRuleAuth"]] = None, **kwargs ): """ @@ -2176,13 +2719,13 @@ def __init__( :keyword auth: Authentication secrets for the custom scale rule. :paramtype auth: list[~azure.mgmt.appcontainers.models.ScaleRuleAuth] """ - super(CustomScaleRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.metadata = metadata self.auth = auth -class Dapr(msrest.serialization.Model): +class Dapr(_serialization.Model): """Container App Dapr configuration. :ivar enabled: Boolean indicating if the Dapr side car is enabled. @@ -2190,17 +2733,32 @@ class Dapr(msrest.serialization.Model): :ivar app_id: Dapr application identifier. :vartype app_id: str :ivar app_protocol: Tells Dapr which protocol your application is using. Valid options are http - and grpc. Default is http. Possible values include: "http", "grpc". + and grpc. Default is http. Known values are: "http" and "grpc". :vartype app_protocol: str or ~azure.mgmt.appcontainers.models.AppProtocol :ivar app_port: Tells Dapr which port your application is listening on. :vartype app_port: int + :ivar http_read_buffer_size: Dapr max size of http header read buffer in KB to handle when + sending multi-KB headers. Default is 65KB. + :vartype http_read_buffer_size: int + :ivar http_max_request_size: Increasing max size of request body http and grpc servers + parameter in MB to handle uploading of big files. Default is 4 MB. + :vartype http_max_request_size: int + :ivar log_level: Sets the log level for the Dapr sidecar. Allowed values are debug, info, warn, + error. Default is info. Known values are: "info", "debug", "warn", and "error". + :vartype log_level: str or ~azure.mgmt.appcontainers.models.LogLevel + :ivar enable_api_logging: Enables API logging for the Dapr sidecar. + :vartype enable_api_logging: bool """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'app_id': {'key': 'appId', 'type': 'str'}, - 'app_protocol': {'key': 'appProtocol', 'type': 'str'}, - 'app_port': {'key': 'appPort', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "app_id": {"key": "appId", "type": "str"}, + "app_protocol": {"key": "appProtocol", "type": "str"}, + "app_port": {"key": "appPort", "type": "int"}, + "http_read_buffer_size": {"key": "httpReadBufferSize", "type": "int"}, + "http_max_request_size": {"key": "httpMaxRequestSize", "type": "int"}, + "log_level": {"key": "logLevel", "type": "str"}, + "enable_api_logging": {"key": "enableApiLogging", "type": "bool"}, } def __init__( @@ -2208,8 +2766,12 @@ def __init__( *, enabled: Optional[bool] = None, app_id: Optional[str] = None, - app_protocol: Optional[Union[str, "AppProtocol"]] = None, + app_protocol: Optional[Union[str, "_models.AppProtocol"]] = None, app_port: Optional[int] = None, + http_read_buffer_size: Optional[int] = None, + http_max_request_size: Optional[int] = None, + log_level: Optional[Union[str, "_models.LogLevel"]] = None, + enable_api_logging: Optional[bool] = None, **kwargs ): """ @@ -2218,19 +2780,34 @@ def __init__( :keyword app_id: Dapr application identifier. :paramtype app_id: str :keyword app_protocol: Tells Dapr which protocol your application is using. Valid options are - http and grpc. Default is http. Possible values include: "http", "grpc". + http and grpc. Default is http. Known values are: "http" and "grpc". :paramtype app_protocol: str or ~azure.mgmt.appcontainers.models.AppProtocol :keyword app_port: Tells Dapr which port your application is listening on. :paramtype app_port: int - """ - super(Dapr, self).__init__(**kwargs) + :keyword http_read_buffer_size: Dapr max size of http header read buffer in KB to handle when + sending multi-KB headers. Default is 65KB. + :paramtype http_read_buffer_size: int + :keyword http_max_request_size: Increasing max size of request body http and grpc servers + parameter in MB to handle uploading of big files. Default is 4 MB. + :paramtype http_max_request_size: int + :keyword log_level: Sets the log level for the Dapr sidecar. Allowed values are debug, info, + warn, error. Default is info. Known values are: "info", "debug", "warn", and "error". + :paramtype log_level: str or ~azure.mgmt.appcontainers.models.LogLevel + :keyword enable_api_logging: Enables API logging for the Dapr sidecar. + :paramtype enable_api_logging: bool + """ + super().__init__(**kwargs) self.enabled = enabled self.app_id = app_id self.app_protocol = app_protocol self.app_port = app_port + self.http_read_buffer_size = http_read_buffer_size + self.http_max_request_size = http_max_request_size + self.log_level = log_level + self.enable_api_logging = enable_api_logging -class DaprComponent(ProxyResource): +class DaprComponent(ProxyResource): # pylint: disable=too-many-instance-attributes """Dapr Component. Variables are only populated by the server, and will be ignored when sending a request. @@ -2256,6 +2833,8 @@ class DaprComponent(ProxyResource): :vartype init_timeout: str :ivar secrets: Collection of secrets used by a Dapr component. :vartype secrets: list[~azure.mgmt.appcontainers.models.Secret] + :ivar secret_store_component: Name of a Dapr component to retrieve component secrets from. + :vartype secret_store_component: str :ivar metadata: Component metadata. :vartype metadata: list[~azure.mgmt.appcontainers.models.DaprMetadata] :ivar scopes: Names of container apps that can use this Dapr component. @@ -2263,24 +2842,25 @@ class DaprComponent(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'component_type': {'key': 'properties.componentType', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'ignore_errors': {'key': 'properties.ignoreErrors', 'type': 'bool'}, - 'init_timeout': {'key': 'properties.initTimeout', 'type': 'str'}, - 'secrets': {'key': 'properties.secrets', 'type': '[Secret]'}, - 'metadata': {'key': 'properties.metadata', 'type': '[DaprMetadata]'}, - 'scopes': {'key': 'properties.scopes', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "component_type": {"key": "properties.componentType", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "ignore_errors": {"key": "properties.ignoreErrors", "type": "bool"}, + "init_timeout": {"key": "properties.initTimeout", "type": "str"}, + "secrets": {"key": "properties.secrets", "type": "[Secret]"}, + "secret_store_component": {"key": "properties.secretStoreComponent", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "[DaprMetadata]"}, + "scopes": {"key": "properties.scopes", "type": "[str]"}, } def __init__( @@ -2290,8 +2870,9 @@ def __init__( version: Optional[str] = None, ignore_errors: Optional[bool] = None, init_timeout: Optional[str] = None, - secrets: Optional[List["Secret"]] = None, - metadata: Optional[List["DaprMetadata"]] = None, + secrets: Optional[List["_models.Secret"]] = None, + secret_store_component: Optional[str] = None, + metadata: Optional[List["_models.DaprMetadata"]] = None, scopes: Optional[List[str]] = None, **kwargs ): @@ -2306,60 +2887,58 @@ def __init__( :paramtype init_timeout: str :keyword secrets: Collection of secrets used by a Dapr component. :paramtype secrets: list[~azure.mgmt.appcontainers.models.Secret] + :keyword secret_store_component: Name of a Dapr component to retrieve component secrets from. + :paramtype secret_store_component: str :keyword metadata: Component metadata. :paramtype metadata: list[~azure.mgmt.appcontainers.models.DaprMetadata] :keyword scopes: Names of container apps that can use this Dapr component. :paramtype scopes: list[str] """ - super(DaprComponent, self).__init__(**kwargs) + super().__init__(**kwargs) self.component_type = component_type self.version = version self.ignore_errors = ignore_errors self.init_timeout = init_timeout self.secrets = secrets + self.secret_store_component = secret_store_component self.metadata = metadata self.scopes = scopes -class DaprComponentsCollection(msrest.serialization.Model): +class DaprComponentsCollection(_serialization.Model): """Dapr Components ARM resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.DaprComponent] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DaprComponent]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DaprComponent]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["DaprComponent"], - **kwargs - ): + def __init__(self, *, value: List["_models.DaprComponent"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.DaprComponent] """ - super(DaprComponentsCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class DaprMetadata(msrest.serialization.Model): +class DaprMetadata(_serialization.Model): """Dapr component metadata. :ivar name: Metadata property name. @@ -2372,18 +2951,13 @@ class DaprMetadata(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'secret_ref': {'key': 'secretRef', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "secret_ref": {"key": "secretRef", "type": "str"}, } def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - secret_ref: Optional[str] = None, - **kwargs + self, *, name: Optional[str] = None, value: Optional[str] = None, secret_ref: Optional[str] = None, **kwargs ): """ :keyword name: Metadata property name. @@ -2394,44 +2968,39 @@ def __init__( value. :paramtype secret_ref: str """ - super(DaprMetadata, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.secret_ref = secret_ref -class DaprSecretsCollection(msrest.serialization.Model): +class DaprSecretsCollection(_serialization.Model): """Dapr component Secrets Collection ARM resource. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of secrets used by a Dapr component. + :ivar value: Collection of secrets used by a Dapr component. Required. :vartype value: list[~azure.mgmt.appcontainers.models.Secret] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Secret]'}, + "value": {"key": "value", "type": "[Secret]"}, } - def __init__( - self, - *, - value: List["Secret"], - **kwargs - ): + def __init__(self, *, value: List["_models.Secret"], **kwargs): """ - :keyword value: Required. Collection of secrets used by a Dapr component. + :keyword value: Collection of secrets used by a Dapr component. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.Secret] """ - super(DaprSecretsCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class DefaultAuthorizationPolicy(msrest.serialization.Model): +class DefaultAuthorizationPolicy(_serialization.Model): """The configuration settings of the Azure Active Directory default authorization policy. :ivar allowed_principals: The configuration settings of the Azure Active Directory allowed @@ -2443,14 +3012,14 @@ class DefaultAuthorizationPolicy(msrest.serialization.Model): """ _attribute_map = { - 'allowed_principals': {'key': 'allowedPrincipals', 'type': 'AllowedPrincipals'}, - 'allowed_applications': {'key': 'allowedApplications', 'type': '[str]'}, + "allowed_principals": {"key": "allowedPrincipals", "type": "AllowedPrincipals"}, + "allowed_applications": {"key": "allowedApplications", "type": "[str]"}, } def __init__( self, *, - allowed_principals: Optional["AllowedPrincipals"] = None, + allowed_principals: Optional["_models.AllowedPrincipals"] = None, allowed_applications: Optional[List[str]] = None, **kwargs ): @@ -2462,12 +3031,12 @@ def __init__( applications. :paramtype allowed_applications: list[str] """ - super(DefaultAuthorizationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_principals = allowed_principals self.allowed_applications = allowed_applications -class DefaultErrorResponse(msrest.serialization.Model): +class DefaultErrorResponse(_serialization.Model): """App Service error response. Variables are only populated by the server, and will be ignored when sending a request. @@ -2477,24 +3046,20 @@ class DefaultErrorResponse(msrest.serialization.Model): """ _validation = { - 'error': {'readonly': True}, + "error": {"readonly": True}, } _attribute_map = { - 'error': {'key': 'error', 'type': 'DefaultErrorResponseError'}, + "error": {"key": "error", "type": "DefaultErrorResponseError"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DefaultErrorResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.error = None -class DefaultErrorResponseError(msrest.serialization.Model): +class DefaultErrorResponseError(_serialization.Model): """Error model. Variables are only populated by the server, and will be ignored when sending a request. @@ -2512,31 +3077,26 @@ class DefaultErrorResponseError(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'innererror': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "innererror": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[DefaultErrorResponseErrorDetailsItem]'}, - 'innererror': {'key': 'innererror', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[DefaultErrorResponseErrorDetailsItem]"}, + "innererror": {"key": "innererror", "type": "str"}, } - def __init__( - self, - *, - details: Optional[List["DefaultErrorResponseErrorDetailsItem"]] = None, - **kwargs - ): + def __init__(self, *, details: Optional[List["_models.DefaultErrorResponseErrorDetailsItem"]] = None, **kwargs): """ :keyword details: Details or the error. :paramtype details: list[~azure.mgmt.appcontainers.models.DefaultErrorResponseErrorDetailsItem] """ - super(DefaultErrorResponseError, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -2544,7 +3104,7 @@ def __init__( self.innererror = None -class DefaultErrorResponseErrorDetailsItem(msrest.serialization.Model): +class DefaultErrorResponseErrorDetailsItem(_serialization.Model): """Detailed errors. Variables are only populated by the server, and will be ignored when sending a request. @@ -2558,30 +3118,580 @@ class DefaultErrorResponseErrorDetailsItem(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + + +class DiagnosticDataProviderMetadata(_serialization.Model): + """Details of a diagnostics data provider. + + :ivar provider_name: Name of data provider. + :vartype provider_name: str + :ivar property_bag: Collection of properties. + :vartype property_bag: + list[~azure.mgmt.appcontainers.models.DiagnosticDataProviderMetadataPropertyBagItem] + """ + + _attribute_map = { + "provider_name": {"key": "providerName", "type": "str"}, + "property_bag": {"key": "propertyBag", "type": "[DiagnosticDataProviderMetadataPropertyBagItem]"}, } def __init__( self, + *, + provider_name: Optional[str] = None, + property_bag: Optional[List["_models.DiagnosticDataProviderMetadataPropertyBagItem"]] = None, **kwargs ): """ + :keyword provider_name: Name of data provider. + :paramtype provider_name: str + :keyword property_bag: Collection of properties. + :paramtype property_bag: + list[~azure.mgmt.appcontainers.models.DiagnosticDataProviderMetadataPropertyBagItem] """ - super(DefaultErrorResponseErrorDetailsItem, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None + super().__init__(**kwargs) + self.provider_name = provider_name + self.property_bag = property_bag + + +class DiagnosticDataProviderMetadataPropertyBagItem(_serialization.Model): + """Property details. + + :ivar name: Property name. + :vartype name: str + :ivar value: Property value. + :vartype value: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs): + """ + :keyword name: Property name. + :paramtype name: str + :keyword value: Property value. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.value = value + + +class DiagnosticDataTableResponseColumn(_serialization.Model): + """Diagnostics data column. + + :ivar column_name: Column name. + :vartype column_name: str + :ivar data_type: Data type of the column. + :vartype data_type: str + :ivar column_type: Column type. + :vartype column_type: str + """ + + _attribute_map = { + "column_name": {"key": "columnName", "type": "str"}, + "data_type": {"key": "dataType", "type": "str"}, + "column_type": {"key": "columnType", "type": "str"}, + } + + def __init__( + self, + *, + column_name: Optional[str] = None, + data_type: Optional[str] = None, + column_type: Optional[str] = None, + **kwargs + ): + """ + :keyword column_name: Column name. + :paramtype column_name: str + :keyword data_type: Data type of the column. + :paramtype data_type: str + :keyword column_type: Column type. + :paramtype column_type: str + """ + super().__init__(**kwargs) + self.column_name = column_name + self.data_type = data_type + self.column_type = column_type + + +class DiagnosticDataTableResponseObject(_serialization.Model): + """Diagnostics data table. + + :ivar table_name: Table name. + :vartype table_name: str + :ivar columns: Columns in the table. + :vartype columns: list[~azure.mgmt.appcontainers.models.DiagnosticDataTableResponseColumn] + :ivar rows: Rows in the table. + :vartype rows: list[JSON] + """ + + _attribute_map = { + "table_name": {"key": "tableName", "type": "str"}, + "columns": {"key": "columns", "type": "[DiagnosticDataTableResponseColumn]"}, + "rows": {"key": "rows", "type": "[object]"}, + } + + def __init__( + self, + *, + table_name: Optional[str] = None, + columns: Optional[List["_models.DiagnosticDataTableResponseColumn"]] = None, + rows: Optional[List[JSON]] = None, + **kwargs + ): + """ + :keyword table_name: Table name. + :paramtype table_name: str + :keyword columns: Columns in the table. + :paramtype columns: list[~azure.mgmt.appcontainers.models.DiagnosticDataTableResponseColumn] + :keyword rows: Rows in the table. + :paramtype rows: list[JSON] + """ + super().__init__(**kwargs) + self.table_name = table_name + self.columns = columns + self.rows = rows + + +class DiagnosticRendering(_serialization.Model): + """Rendering details of a diagnostics table. + + :ivar type: Rendering type. + :vartype type: int + :ivar title: Title of the table. + :vartype title: str + :ivar description: Description of the table. + :vartype description: str + :ivar is_visible: Flag if the table should be rendered. + :vartype is_visible: bool + """ + + _attribute_map = { + "type": {"key": "type", "type": "int"}, + "title": {"key": "title", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "is_visible": {"key": "isVisible", "type": "bool"}, + } + + def __init__( + self, + *, + type: Optional[int] = None, + title: Optional[str] = None, + description: Optional[str] = None, + is_visible: Optional[bool] = None, + **kwargs + ): + """ + :keyword type: Rendering type. + :paramtype type: int + :keyword title: Title of the table. + :paramtype title: str + :keyword description: Description of the table. + :paramtype description: str + :keyword is_visible: Flag if the table should be rendered. + :paramtype is_visible: bool + """ + super().__init__(**kwargs) + self.type = type + self.title = title + self.description = description + self.is_visible = is_visible + +class Diagnostics(ProxyResource): + """Diagnostics data for a resource. -class EnvironmentVar(msrest.serialization.Model): + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData + :ivar properties: Diagnostics resource specific properties. + :vartype properties: ~azure.mgmt.appcontainers.models.DiagnosticsProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "DiagnosticsProperties"}, + } + + def __init__(self, *, properties: Optional["_models.DiagnosticsProperties"] = None, **kwargs): + """ + :keyword properties: Diagnostics resource specific properties. + :paramtype properties: ~azure.mgmt.appcontainers.models.DiagnosticsProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class DiagnosticsCollection(_serialization.Model): + """Diagnostics data collection for a resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar value: Collection of diagnostic data. Required. + :vartype value: list[~azure.mgmt.appcontainers.models.Diagnostics] + :ivar next_link: Link to next page of resources. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Diagnostics]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.Diagnostics"], **kwargs): + """ + :keyword value: Collection of diagnostic data. Required. + :paramtype value: list[~azure.mgmt.appcontainers.models.Diagnostics] + """ + super().__init__(**kwargs) + self.value = value + self.next_link = None + + +class DiagnosticsDataApiResponse(_serialization.Model): + """Diagnostics data returned from a detector. + + :ivar table: Table response. + :vartype table: ~azure.mgmt.appcontainers.models.DiagnosticDataTableResponseObject + :ivar rendering_properties: Details of the table response. + :vartype rendering_properties: ~azure.mgmt.appcontainers.models.DiagnosticRendering + """ + + _attribute_map = { + "table": {"key": "table", "type": "DiagnosticDataTableResponseObject"}, + "rendering_properties": {"key": "renderingProperties", "type": "DiagnosticRendering"}, + } + + def __init__( + self, + *, + table: Optional["_models.DiagnosticDataTableResponseObject"] = None, + rendering_properties: Optional["_models.DiagnosticRendering"] = None, + **kwargs + ): + """ + :keyword table: Table response. + :paramtype table: ~azure.mgmt.appcontainers.models.DiagnosticDataTableResponseObject + :keyword rendering_properties: Details of the table response. + :paramtype rendering_properties: ~azure.mgmt.appcontainers.models.DiagnosticRendering + """ + super().__init__(**kwargs) + self.table = table + self.rendering_properties = rendering_properties + + +class DiagnosticsDefinition(_serialization.Model): + """Metadata of the diagnostics response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Unique detector name. + :vartype id: str + :ivar name: Display Name of the detector. + :vartype name: str + :ivar description: Details of the diagnostics info. + :vartype description: str + :ivar author: Authors' names of the detector. + :vartype author: str + :ivar category: Category of the detector. + :vartype category: str + :ivar support_topic_list: List of support topics. + :vartype support_topic_list: list[~azure.mgmt.appcontainers.models.DiagnosticSupportTopic] + :ivar analysis_types: List of analysis types. + :vartype analysis_types: list[str] + :ivar type: Authors' names of the detector. + :vartype type: str + :ivar score: Authors' names of the detector. + :vartype score: float + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "description": {"readonly": True}, + "author": {"readonly": True}, + "category": {"readonly": True}, + "type": {"readonly": True}, + "score": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "author": {"key": "author", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "support_topic_list": {"key": "supportTopicList", "type": "[DiagnosticSupportTopic]"}, + "analysis_types": {"key": "analysisTypes", "type": "[str]"}, + "type": {"key": "type", "type": "str"}, + "score": {"key": "score", "type": "float"}, + } + + def __init__( + self, + *, + support_topic_list: Optional[List["_models.DiagnosticSupportTopic"]] = None, + analysis_types: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword support_topic_list: List of support topics. + :paramtype support_topic_list: list[~azure.mgmt.appcontainers.models.DiagnosticSupportTopic] + :keyword analysis_types: List of analysis types. + :paramtype analysis_types: list[str] + """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.description = None + self.author = None + self.category = None + self.support_topic_list = support_topic_list + self.analysis_types = analysis_types + self.type = None + self.score = None + + +class DiagnosticsProperties(_serialization.Model): + """Diagnostics resource specific properties. + + :ivar metadata: Metadata of the diagnostics response. + :vartype metadata: ~azure.mgmt.appcontainers.models.DiagnosticsDefinition + :ivar dataset: Set of data collections associated with the response. + :vartype dataset: list[~azure.mgmt.appcontainers.models.DiagnosticsDataApiResponse] + :ivar status: Status of the diagnostics response. + :vartype status: ~azure.mgmt.appcontainers.models.DiagnosticsStatus + :ivar data_provider_metadata: List of data providers' metadata. + :vartype data_provider_metadata: + ~azure.mgmt.appcontainers.models.DiagnosticDataProviderMetadata + """ + + _attribute_map = { + "metadata": {"key": "metadata", "type": "DiagnosticsDefinition"}, + "dataset": {"key": "dataset", "type": "[DiagnosticsDataApiResponse]"}, + "status": {"key": "status", "type": "DiagnosticsStatus"}, + "data_provider_metadata": {"key": "dataProviderMetadata", "type": "DiagnosticDataProviderMetadata"}, + } + + def __init__( + self, + *, + metadata: Optional["_models.DiagnosticsDefinition"] = None, + dataset: Optional[List["_models.DiagnosticsDataApiResponse"]] = None, + status: Optional["_models.DiagnosticsStatus"] = None, + data_provider_metadata: Optional["_models.DiagnosticDataProviderMetadata"] = None, + **kwargs + ): + """ + :keyword metadata: Metadata of the diagnostics response. + :paramtype metadata: ~azure.mgmt.appcontainers.models.DiagnosticsDefinition + :keyword dataset: Set of data collections associated with the response. + :paramtype dataset: list[~azure.mgmt.appcontainers.models.DiagnosticsDataApiResponse] + :keyword status: Status of the diagnostics response. + :paramtype status: ~azure.mgmt.appcontainers.models.DiagnosticsStatus + :keyword data_provider_metadata: List of data providers' metadata. + :paramtype data_provider_metadata: + ~azure.mgmt.appcontainers.models.DiagnosticDataProviderMetadata + """ + super().__init__(**kwargs) + self.metadata = metadata + self.dataset = dataset + self.status = status + self.data_provider_metadata = data_provider_metadata + + +class DiagnosticsStatus(_serialization.Model): + """Rendering details of a diagnostics table. + + :ivar message: Diagnostic message. + :vartype message: str + :ivar status_id: Status. + :vartype status_id: int + """ + + _attribute_map = { + "message": {"key": "message", "type": "str"}, + "status_id": {"key": "statusId", "type": "int"}, + } + + def __init__(self, *, message: Optional[str] = None, status_id: Optional[int] = None, **kwargs): + """ + :keyword message: Diagnostic message. + :paramtype message: str + :keyword status_id: Status. + :paramtype status_id: int + """ + super().__init__(**kwargs) + self.message = message + self.status_id = status_id + + +class DiagnosticSupportTopic(_serialization.Model): + """Support topic information. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Unique topic identifier. + :vartype id: str + :ivar pes_id: PES identifier. + :vartype pes_id: str + """ + + _validation = { + "id": {"readonly": True}, + "pes_id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "pes_id": {"key": "pesId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.pes_id = None + + +class EnvironmentAuthToken(TrackedResource): + """Environment Auth Token. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar token: Auth token value. + :vartype token: str + :ivar expires: Token expiration date. + :vartype expires: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "token": {"readonly": True}, + "expires": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "token": {"key": "properties.token", "type": "str"}, + "expires": {"key": "properties.expires", "type": "iso-8601"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(tags=tags, location=location, **kwargs) + self.token = None + self.expires = None + + +class EnvironmentSkuProperties(_serialization.Model): + """Managed Environment resource SKU properties. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name of the Sku. Required. Known values are: "Consumption" and "Premium". + :vartype name: str or ~azure.mgmt.appcontainers.models.SkuName + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): + """ + :keyword name: Name of the Sku. Required. Known values are: "Consumption" and "Premium". + :paramtype name: str or ~azure.mgmt.appcontainers.models.SkuName + """ + super().__init__(**kwargs) + self.name = name + + +class EnvironmentVar(_serialization.Model): """Container App container environment variable. :ivar name: Environment variable name. @@ -2594,18 +3704,13 @@ class EnvironmentVar(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'secret_ref': {'key': 'secretRef', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "secret_ref": {"key": "secretRef", "type": "str"}, } def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - secret_ref: Optional[str] = None, - **kwargs + self, *, name: Optional[str] = None, value: Optional[str] = None, secret_ref: Optional[str] = None, **kwargs ): """ :keyword name: Environment variable name. @@ -2616,13 +3721,45 @@ def __init__( variable value. :paramtype secret_ref: str """ - super(EnvironmentVar, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value self.secret_ref = secret_ref -class Facebook(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): + """The complex type of the extended location. + + :ivar name: The name of the extended location. + :vartype name: str + :ivar type: The type of the extended location. "CustomLocation" + :vartype type: str or ~azure.mgmt.appcontainers.models.ExtendedLocationTypes + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, + **kwargs + ): + """ + :keyword name: The name of the extended location. + :paramtype name: str + :keyword type: The type of the extended location. "CustomLocation" + :paramtype type: str or ~azure.mgmt.appcontainers.models.ExtendedLocationTypes + """ + super().__init__(**kwargs) + self.name = name + self.type = type + + +class Facebook(_serialization.Model): """The configuration settings of the Facebook provider. :ivar enabled: :code:`false` if the Facebook provider should not be enabled @@ -2638,19 +3775,19 @@ class Facebook(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'AppRegistration'}, - 'graph_api_version': {'key': 'graphApiVersion', 'type': 'str'}, - 'login': {'key': 'login', 'type': 'LoginScopes'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "AppRegistration"}, + "graph_api_version": {"key": "graphApiVersion", "type": "str"}, + "login": {"key": "login", "type": "LoginScopes"}, } def __init__( self, *, enabled: Optional[bool] = None, - registration: Optional["AppRegistration"] = None, + registration: Optional["_models.AppRegistration"] = None, graph_api_version: Optional[str] = None, - login: Optional["LoginScopes"] = None, + login: Optional["_models.LoginScopes"] = None, **kwargs ): """ @@ -2665,18 +3802,18 @@ def __init__( :keyword login: The configuration settings of the login flow. :paramtype login: ~azure.mgmt.appcontainers.models.LoginScopes """ - super(Facebook, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration self.graph_api_version = graph_api_version self.login = login -class ForwardProxy(msrest.serialization.Model): +class ForwardProxy(_serialization.Model): """The configuration settings of a forward proxy used to make the requests. - :ivar convention: The convention used to determine the url of the request made. Possible values - include: "NoProxy", "Standard", "Custom". + :ivar convention: The convention used to determine the url of the request made. Known values + are: "NoProxy", "Standard", and "Custom". :vartype convention: str or ~azure.mgmt.appcontainers.models.ForwardProxyConvention :ivar custom_host_header_name: The name of the header containing the host of the request. :vartype custom_host_header_name: str @@ -2685,35 +3822,35 @@ class ForwardProxy(msrest.serialization.Model): """ _attribute_map = { - 'convention': {'key': 'convention', 'type': 'str'}, - 'custom_host_header_name': {'key': 'customHostHeaderName', 'type': 'str'}, - 'custom_proto_header_name': {'key': 'customProtoHeaderName', 'type': 'str'}, + "convention": {"key": "convention", "type": "str"}, + "custom_host_header_name": {"key": "customHostHeaderName", "type": "str"}, + "custom_proto_header_name": {"key": "customProtoHeaderName", "type": "str"}, } def __init__( self, *, - convention: Optional[Union[str, "ForwardProxyConvention"]] = None, + convention: Optional[Union[str, "_models.ForwardProxyConvention"]] = None, custom_host_header_name: Optional[str] = None, custom_proto_header_name: Optional[str] = None, **kwargs ): """ - :keyword convention: The convention used to determine the url of the request made. Possible - values include: "NoProxy", "Standard", "Custom". + :keyword convention: The convention used to determine the url of the request made. Known values + are: "NoProxy", "Standard", and "Custom". :paramtype convention: str or ~azure.mgmt.appcontainers.models.ForwardProxyConvention :keyword custom_host_header_name: The name of the header containing the host of the request. :paramtype custom_host_header_name: str :keyword custom_proto_header_name: The name of the header containing the scheme of the request. :paramtype custom_proto_header_name: str """ - super(ForwardProxy, self).__init__(**kwargs) + super().__init__(**kwargs) self.convention = convention self.custom_host_header_name = custom_host_header_name self.custom_proto_header_name = custom_proto_header_name -class GitHub(msrest.serialization.Model): +class GitHub(_serialization.Model): """The configuration settings of the GitHub provider. :ivar enabled: :code:`false` if the GitHub provider should not be enabled despite @@ -2726,17 +3863,17 @@ class GitHub(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'ClientRegistration'}, - 'login': {'key': 'login', 'type': 'LoginScopes'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "ClientRegistration"}, + "login": {"key": "login", "type": "LoginScopes"}, } def __init__( self, *, enabled: Optional[bool] = None, - registration: Optional["ClientRegistration"] = None, - login: Optional["LoginScopes"] = None, + registration: Optional["_models.ClientRegistration"] = None, + login: Optional["_models.LoginScopes"] = None, **kwargs ): """ @@ -2749,13 +3886,13 @@ def __init__( :keyword login: The configuration settings of the login flow. :paramtype login: ~azure.mgmt.appcontainers.models.LoginScopes """ - super(GitHub, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration self.login = login -class GithubActionConfiguration(msrest.serialization.Model): +class GithubActionConfiguration(_serialization.Model): """Configuration properties that define the mutable settings of a Container App SourceControl. :ivar registry_info: Registry configurations. @@ -2777,21 +3914,21 @@ class GithubActionConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'registry_info': {'key': 'registryInfo', 'type': 'RegistryInfo'}, - 'azure_credentials': {'key': 'azureCredentials', 'type': 'AzureCredentials'}, - 'context_path': {'key': 'contextPath', 'type': 'str'}, - 'image': {'key': 'image', 'type': 'str'}, - 'publish_type': {'key': 'publishType', 'type': 'str'}, - 'os': {'key': 'os', 'type': 'str'}, - 'runtime_stack': {'key': 'runtimeStack', 'type': 'str'}, - 'runtime_version': {'key': 'runtimeVersion', 'type': 'str'}, + "registry_info": {"key": "registryInfo", "type": "RegistryInfo"}, + "azure_credentials": {"key": "azureCredentials", "type": "AzureCredentials"}, + "context_path": {"key": "contextPath", "type": "str"}, + "image": {"key": "image", "type": "str"}, + "publish_type": {"key": "publishType", "type": "str"}, + "os": {"key": "os", "type": "str"}, + "runtime_stack": {"key": "runtimeStack", "type": "str"}, + "runtime_version": {"key": "runtimeVersion", "type": "str"}, } def __init__( self, *, - registry_info: Optional["RegistryInfo"] = None, - azure_credentials: Optional["AzureCredentials"] = None, + registry_info: Optional["_models.RegistryInfo"] = None, + azure_credentials: Optional["_models.AzureCredentials"] = None, context_path: Optional[str] = None, image: Optional[str] = None, publish_type: Optional[str] = None, @@ -2818,7 +3955,7 @@ def __init__( :keyword runtime_version: Runtime version. :paramtype runtime_version: str """ - super(GithubActionConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.registry_info = registry_info self.azure_credentials = azure_credentials self.context_path = context_path @@ -2829,12 +3966,12 @@ def __init__( self.runtime_version = runtime_version -class GlobalValidation(msrest.serialization.Model): +class GlobalValidation(_serialization.Model): """The configuration settings that determines the validation flow of users using ContainerApp Service Authentication/Authorization. :ivar unauthenticated_client_action: The action to take when an unauthenticated client attempts - to access the app. Possible values include: "RedirectToLoginPage", "AllowAnonymous", - "Return401", "Return403". + to access the app. Known values are: "RedirectToLoginPage", "AllowAnonymous", "Return401", and + "Return403". :vartype unauthenticated_client_action: str or ~azure.mgmt.appcontainers.models.UnauthenticatedClientActionV2 :ivar redirect_to_provider: The default authentication provider to use when multiple providers @@ -2849,23 +3986,23 @@ class GlobalValidation(msrest.serialization.Model): """ _attribute_map = { - 'unauthenticated_client_action': {'key': 'unauthenticatedClientAction', 'type': 'str'}, - 'redirect_to_provider': {'key': 'redirectToProvider', 'type': 'str'}, - 'excluded_paths': {'key': 'excludedPaths', 'type': '[str]'}, + "unauthenticated_client_action": {"key": "unauthenticatedClientAction", "type": "str"}, + "redirect_to_provider": {"key": "redirectToProvider", "type": "str"}, + "excluded_paths": {"key": "excludedPaths", "type": "[str]"}, } def __init__( self, *, - unauthenticated_client_action: Optional[Union[str, "UnauthenticatedClientActionV2"]] = None, + unauthenticated_client_action: Optional[Union[str, "_models.UnauthenticatedClientActionV2"]] = None, redirect_to_provider: Optional[str] = None, excluded_paths: Optional[List[str]] = None, **kwargs ): """ :keyword unauthenticated_client_action: The action to take when an unauthenticated client - attempts to access the app. Possible values include: "RedirectToLoginPage", "AllowAnonymous", - "Return401", "Return403". + attempts to access the app. Known values are: "RedirectToLoginPage", "AllowAnonymous", + "Return401", and "Return403". :paramtype unauthenticated_client_action: str or ~azure.mgmt.appcontainers.models.UnauthenticatedClientActionV2 :keyword redirect_to_provider: The default authentication provider to use when multiple @@ -2878,13 +4015,13 @@ def __init__( the login page. :paramtype excluded_paths: list[str] """ - super(GlobalValidation, self).__init__(**kwargs) + super().__init__(**kwargs) self.unauthenticated_client_action = unauthenticated_client_action self.redirect_to_provider = redirect_to_provider self.excluded_paths = excluded_paths -class Google(msrest.serialization.Model): +class Google(_serialization.Model): """The configuration settings of the Google provider. :ivar enabled: :code:`false` if the Google provider should not be enabled despite @@ -2900,19 +4037,19 @@ class Google(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'ClientRegistration'}, - 'login': {'key': 'login', 'type': 'LoginScopes'}, - 'validation': {'key': 'validation', 'type': 'AllowedAudiencesValidation'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "ClientRegistration"}, + "login": {"key": "login", "type": "LoginScopes"}, + "validation": {"key": "validation", "type": "AllowedAudiencesValidation"}, } def __init__( self, *, enabled: Optional[bool] = None, - registration: Optional["ClientRegistration"] = None, - login: Optional["LoginScopes"] = None, - validation: Optional["AllowedAudiencesValidation"] = None, + registration: Optional["_models.ClientRegistration"] = None, + login: Optional["_models.LoginScopes"] = None, + validation: Optional["_models.AllowedAudiencesValidation"] = None, **kwargs ): """ @@ -2928,15 +4065,15 @@ def __init__( flow. :paramtype validation: ~azure.mgmt.appcontainers.models.AllowedAudiencesValidation """ - super(Google, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration self.login = login self.validation = validation -class HttpScaleRule(msrest.serialization.Model): - """Container App container Custom scaling rule. +class HttpScaleRule(_serialization.Model): + """Container App container Http scaling rule. :ivar metadata: Metadata properties to describe http scale rule. :vartype metadata: dict[str, str] @@ -2945,15 +4082,15 @@ class HttpScaleRule(msrest.serialization.Model): """ _attribute_map = { - 'metadata': {'key': 'metadata', 'type': '{str}'}, - 'auth': {'key': 'auth', 'type': '[ScaleRuleAuth]'}, + "metadata": {"key": "metadata", "type": "{str}"}, + "auth": {"key": "auth", "type": "[ScaleRuleAuth]"}, } def __init__( self, *, metadata: Optional[Dict[str, str]] = None, - auth: Optional[List["ScaleRuleAuth"]] = None, + auth: Optional[List["_models.ScaleRuleAuth"]] = None, **kwargs ): """ @@ -2962,12 +4099,12 @@ def __init__( :keyword auth: Authentication secrets for the custom scale rule. :paramtype auth: list[~azure.mgmt.appcontainers.models.ScaleRuleAuth] """ - super(HttpScaleRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.auth = auth -class HttpSettings(msrest.serialization.Model): +class HttpSettings(_serialization.Model): """The configuration settings of the HTTP requests for authentication and authorization requests made against ContainerApp Service Authentication/Authorization. :ivar require_https: :code:`false` if the authentication/authorization responses @@ -2980,17 +4117,17 @@ class HttpSettings(msrest.serialization.Model): """ _attribute_map = { - 'require_https': {'key': 'requireHttps', 'type': 'bool'}, - 'routes': {'key': 'routes', 'type': 'HttpSettingsRoutes'}, - 'forward_proxy': {'key': 'forwardProxy', 'type': 'ForwardProxy'}, + "require_https": {"key": "requireHttps", "type": "bool"}, + "routes": {"key": "routes", "type": "HttpSettingsRoutes"}, + "forward_proxy": {"key": "forwardProxy", "type": "ForwardProxy"}, } def __init__( self, *, require_https: Optional[bool] = None, - routes: Optional["HttpSettingsRoutes"] = None, - forward_proxy: Optional["ForwardProxy"] = None, + routes: Optional["_models.HttpSettingsRoutes"] = None, + forward_proxy: Optional["_models.ForwardProxy"] = None, **kwargs ): """ @@ -3003,13 +4140,13 @@ def __init__( requests. :paramtype forward_proxy: ~azure.mgmt.appcontainers.models.ForwardProxy """ - super(HttpSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.require_https = require_https self.routes = routes self.forward_proxy = forward_proxy -class HttpSettingsRoutes(msrest.serialization.Model): +class HttpSettingsRoutes(_serialization.Model): """The configuration settings of the paths HTTP requests. :ivar api_prefix: The prefix that should precede all the authentication/authorization paths. @@ -3017,24 +4154,19 @@ class HttpSettingsRoutes(msrest.serialization.Model): """ _attribute_map = { - 'api_prefix': {'key': 'apiPrefix', 'type': 'str'}, + "api_prefix": {"key": "apiPrefix", "type": "str"}, } - def __init__( - self, - *, - api_prefix: Optional[str] = None, - **kwargs - ): + def __init__(self, *, api_prefix: Optional[str] = None, **kwargs): """ :keyword api_prefix: The prefix that should precede all the authentication/authorization paths. :paramtype api_prefix: str """ - super(HttpSettingsRoutes, self).__init__(**kwargs) + super().__init__(**kwargs) self.api_prefix = api_prefix -class IdentityProviders(msrest.serialization.Model): +class IdentityProviders(_serialization.Model): """The configuration settings of each of the identity providers used to configure ContainerApp Service Authentication/Authorization. :ivar azure_active_directory: The configuration settings of the Azure Active directory @@ -3060,27 +4192,30 @@ class IdentityProviders(msrest.serialization.Model): """ _attribute_map = { - 'azure_active_directory': {'key': 'azureActiveDirectory', 'type': 'AzureActiveDirectory'}, - 'facebook': {'key': 'facebook', 'type': 'Facebook'}, - 'git_hub': {'key': 'gitHub', 'type': 'GitHub'}, - 'google': {'key': 'google', 'type': 'Google'}, - 'twitter': {'key': 'twitter', 'type': 'Twitter'}, - 'apple': {'key': 'apple', 'type': 'Apple'}, - 'azure_static_web_apps': {'key': 'azureStaticWebApps', 'type': 'AzureStaticWebApps'}, - 'custom_open_id_connect_providers': {'key': 'customOpenIdConnectProviders', 'type': '{CustomOpenIdConnectProvider}'}, + "azure_active_directory": {"key": "azureActiveDirectory", "type": "AzureActiveDirectory"}, + "facebook": {"key": "facebook", "type": "Facebook"}, + "git_hub": {"key": "gitHub", "type": "GitHub"}, + "google": {"key": "google", "type": "Google"}, + "twitter": {"key": "twitter", "type": "Twitter"}, + "apple": {"key": "apple", "type": "Apple"}, + "azure_static_web_apps": {"key": "azureStaticWebApps", "type": "AzureStaticWebApps"}, + "custom_open_id_connect_providers": { + "key": "customOpenIdConnectProviders", + "type": "{CustomOpenIdConnectProvider}", + }, } def __init__( self, *, - azure_active_directory: Optional["AzureActiveDirectory"] = None, - facebook: Optional["Facebook"] = None, - git_hub: Optional["GitHub"] = None, - google: Optional["Google"] = None, - twitter: Optional["Twitter"] = None, - apple: Optional["Apple"] = None, - azure_static_web_apps: Optional["AzureStaticWebApps"] = None, - custom_open_id_connect_providers: Optional[Dict[str, "CustomOpenIdConnectProvider"]] = None, + azure_active_directory: Optional["_models.AzureActiveDirectory"] = None, + facebook: Optional["_models.Facebook"] = None, + git_hub: Optional["_models.GitHub"] = None, + google: Optional["_models.Google"] = None, + twitter: Optional["_models.Twitter"] = None, + apple: Optional["_models.Apple"] = None, + azure_static_web_apps: Optional["_models.AzureStaticWebApps"] = None, + custom_open_id_connect_providers: Optional[Dict[str, "_models.CustomOpenIdConnectProvider"]] = None, **kwargs ): """ @@ -3106,7 +4241,7 @@ def __init__( :paramtype custom_open_id_connect_providers: dict[str, ~azure.mgmt.appcontainers.models.CustomOpenIdConnectProvider] """ - super(IdentityProviders, self).__init__(**kwargs) + super().__init__(**kwargs) self.azure_active_directory = azure_active_directory self.facebook = facebook self.git_hub = git_hub @@ -3117,7 +4252,7 @@ def __init__( self.custom_open_id_connect_providers = custom_open_id_connect_providers -class Ingress(msrest.serialization.Model): +class Ingress(_serialization.Model): """Container App Ingress configuration. Variables are only populated by the server, and will be ignored when sending a request. @@ -3128,7 +4263,10 @@ class Ingress(msrest.serialization.Model): :vartype external: bool :ivar target_port: Target Port in containers for traffic from ingress. :vartype target_port: int - :ivar transport: Ingress transport protocol. Possible values include: "auto", "http", "http2". + :ivar exposed_port: Exposed Port in containers for TCP traffic from ingress. + :vartype exposed_port: int + :ivar transport: Ingress transport protocol. Known values are: "auto", "http", "http2", and + "tcp". :vartype transport: str or ~azure.mgmt.appcontainers.models.IngressTransportMethod :ivar traffic: Traffic weights for app's revisions. :vartype traffic: list[~azure.mgmt.appcontainers.models.TrafficWeight] @@ -3137,31 +4275,38 @@ class Ingress(msrest.serialization.Model): :ivar allow_insecure: Bool indicating if HTTP connections to is allowed. If set to false HTTP connections are automatically redirected to HTTPS connections. :vartype allow_insecure: bool + :ivar ip_security_restrictions: Rules to restrict incoming IP address. + :vartype ip_security_restrictions: + list[~azure.mgmt.appcontainers.models.IpSecurityRestrictionRule] """ _validation = { - 'fqdn': {'readonly': True}, + "fqdn": {"readonly": True}, } _attribute_map = { - 'fqdn': {'key': 'fqdn', 'type': 'str'}, - 'external': {'key': 'external', 'type': 'bool'}, - 'target_port': {'key': 'targetPort', 'type': 'int'}, - 'transport': {'key': 'transport', 'type': 'str'}, - 'traffic': {'key': 'traffic', 'type': '[TrafficWeight]'}, - 'custom_domains': {'key': 'customDomains', 'type': '[CustomDomain]'}, - 'allow_insecure': {'key': 'allowInsecure', 'type': 'bool'}, + "fqdn": {"key": "fqdn", "type": "str"}, + "external": {"key": "external", "type": "bool"}, + "target_port": {"key": "targetPort", "type": "int"}, + "exposed_port": {"key": "exposedPort", "type": "int"}, + "transport": {"key": "transport", "type": "str"}, + "traffic": {"key": "traffic", "type": "[TrafficWeight]"}, + "custom_domains": {"key": "customDomains", "type": "[CustomDomain]"}, + "allow_insecure": {"key": "allowInsecure", "type": "bool"}, + "ip_security_restrictions": {"key": "ipSecurityRestrictions", "type": "[IpSecurityRestrictionRule]"}, } def __init__( self, *, - external: Optional[bool] = False, + external: bool = False, target_port: Optional[int] = None, - transport: Optional[Union[str, "IngressTransportMethod"]] = None, - traffic: Optional[List["TrafficWeight"]] = None, - custom_domains: Optional[List["CustomDomain"]] = None, + exposed_port: Optional[int] = None, + transport: Optional[Union[str, "_models.IngressTransportMethod"]] = None, + traffic: Optional[List["_models.TrafficWeight"]] = None, + custom_domains: Optional[List["_models.CustomDomain"]] = None, allow_insecure: Optional[bool] = None, + ip_security_restrictions: Optional[List["_models.IpSecurityRestrictionRule"]] = None, **kwargs ): """ @@ -3169,8 +4314,10 @@ def __init__( :paramtype external: bool :keyword target_port: Target Port in containers for traffic from ingress. :paramtype target_port: int - :keyword transport: Ingress transport protocol. Possible values include: "auto", "http", - "http2". + :keyword exposed_port: Exposed Port in containers for TCP traffic from ingress. + :paramtype exposed_port: int + :keyword transport: Ingress transport protocol. Known values are: "auto", "http", "http2", and + "tcp". :paramtype transport: str or ~azure.mgmt.appcontainers.models.IngressTransportMethod :keyword traffic: Traffic weights for app's revisions. :paramtype traffic: list[~azure.mgmt.appcontainers.models.TrafficWeight] @@ -3179,18 +4326,150 @@ def __init__( :keyword allow_insecure: Bool indicating if HTTP connections to is allowed. If set to false HTTP connections are automatically redirected to HTTPS connections. :paramtype allow_insecure: bool + :keyword ip_security_restrictions: Rules to restrict incoming IP address. + :paramtype ip_security_restrictions: + list[~azure.mgmt.appcontainers.models.IpSecurityRestrictionRule] """ - super(Ingress, self).__init__(**kwargs) + super().__init__(**kwargs) self.fqdn = None self.external = external self.target_port = target_port + self.exposed_port = exposed_port self.transport = transport self.traffic = traffic self.custom_domains = custom_domains self.allow_insecure = allow_insecure + self.ip_security_restrictions = ip_security_restrictions + + +class InitContainer(BaseContainer): + """Container App init container definition. + + :ivar image: Container image tag. + :vartype image: str + :ivar name: Custom container name. + :vartype name: str + :ivar command: Container start command. + :vartype command: list[str] + :ivar args: Container start command arguments. + :vartype args: list[str] + :ivar env: Container environment variables. + :vartype env: list[~azure.mgmt.appcontainers.models.EnvironmentVar] + :ivar resources: Container resource requirements. + :vartype resources: ~azure.mgmt.appcontainers.models.ContainerResources + :ivar volume_mounts: Container volume mounts. + :vartype volume_mounts: list[~azure.mgmt.appcontainers.models.VolumeMount] + """ + + _attribute_map = { + "image": {"key": "image", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "command": {"key": "command", "type": "[str]"}, + "args": {"key": "args", "type": "[str]"}, + "env": {"key": "env", "type": "[EnvironmentVar]"}, + "resources": {"key": "resources", "type": "ContainerResources"}, + "volume_mounts": {"key": "volumeMounts", "type": "[VolumeMount]"}, + } + + def __init__( + self, + *, + image: Optional[str] = None, + name: Optional[str] = None, + command: Optional[List[str]] = None, + args: Optional[List[str]] = None, + env: Optional[List["_models.EnvironmentVar"]] = None, + resources: Optional["_models.ContainerResources"] = None, + volume_mounts: Optional[List["_models.VolumeMount"]] = None, + **kwargs + ): + """ + :keyword image: Container image tag. + :paramtype image: str + :keyword name: Custom container name. + :paramtype name: str + :keyword command: Container start command. + :paramtype command: list[str] + :keyword args: Container start command arguments. + :paramtype args: list[str] + :keyword env: Container environment variables. + :paramtype env: list[~azure.mgmt.appcontainers.models.EnvironmentVar] + :keyword resources: Container resource requirements. + :paramtype resources: ~azure.mgmt.appcontainers.models.ContainerResources + :keyword volume_mounts: Container volume mounts. + :paramtype volume_mounts: list[~azure.mgmt.appcontainers.models.VolumeMount] + """ + super().__init__( + image=image, + name=name, + command=command, + args=args, + env=env, + resources=resources, + volume_mounts=volume_mounts, + **kwargs + ) + + +class IpSecurityRestrictionRule(_serialization.Model): + """Rule to restrict incoming IP address. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Name for the IP restriction rule. Required. + :vartype name: str + :ivar description: Describe the IP restriction rule that is being sent to the container-app. + This is an optional field. + :vartype description: str + :ivar ip_address_range: CIDR notation to match incoming IP address. Required. + :vartype ip_address_range: str + :ivar action: Allow or Deny rules to determine for incoming IP. Note: Rules can only consist of + ALL Allow or ALL Deny. Required. Known values are: "Allow" and "Deny". + :vartype action: str or ~azure.mgmt.appcontainers.models.Action + """ + + _validation = { + "name": {"required": True}, + "ip_address_range": {"required": True}, + "action": {"required": True}, + } + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "ip_address_range": {"key": "ipAddressRange", "type": "str"}, + "action": {"key": "action", "type": "str"}, + } + + def __init__( + self, + *, + name: str, + ip_address_range: str, + action: Union[str, "_models.Action"], + description: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name for the IP restriction rule. Required. + :paramtype name: str + :keyword description: Describe the IP restriction rule that is being sent to the container-app. + This is an optional field. + :paramtype description: str + :keyword ip_address_range: CIDR notation to match incoming IP address. Required. + :paramtype ip_address_range: str + :keyword action: Allow or Deny rules to determine for incoming IP. Note: Rules can only consist + of ALL Allow or ALL Deny. Required. Known values are: "Allow" and "Deny". + :paramtype action: str or ~azure.mgmt.appcontainers.models.Action + """ + super().__init__(**kwargs) + self.name = name + self.description = description + self.ip_address_range = ip_address_range + self.action = action -class JwtClaimChecks(msrest.serialization.Model): + +class JwtClaimChecks(_serialization.Model): """The configuration settings of the checks that should be made while validating the JWT Claims. :ivar allowed_groups: The list of the allowed groups. @@ -3200,8 +4479,8 @@ class JwtClaimChecks(msrest.serialization.Model): """ _attribute_map = { - 'allowed_groups': {'key': 'allowedGroups', 'type': '[str]'}, - 'allowed_client_applications': {'key': 'allowedClientApplications', 'type': '[str]'}, + "allowed_groups": {"key": "allowedGroups", "type": "[str]"}, + "allowed_client_applications": {"key": "allowedClientApplications", "type": "[str]"}, } def __init__( @@ -3217,12 +4496,12 @@ def __init__( :keyword allowed_client_applications: The list of the allowed client applications. :paramtype allowed_client_applications: list[str] """ - super(JwtClaimChecks, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_groups = allowed_groups self.allowed_client_applications = allowed_client_applications -class LogAnalyticsConfiguration(msrest.serialization.Model): +class LogAnalyticsConfiguration(_serialization.Model): """Log analytics configuration. :ivar customer_id: Log analytics customer id. @@ -3232,29 +4511,23 @@ class LogAnalyticsConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'customer_id': {'key': 'customerId', 'type': 'str'}, - 'shared_key': {'key': 'sharedKey', 'type': 'str'}, + "customer_id": {"key": "customerId", "type": "str"}, + "shared_key": {"key": "sharedKey", "type": "str"}, } - def __init__( - self, - *, - customer_id: Optional[str] = None, - shared_key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, customer_id: Optional[str] = None, shared_key: Optional[str] = None, **kwargs): """ :keyword customer_id: Log analytics customer id. :paramtype customer_id: str :keyword shared_key: Log analytics customer key. :paramtype shared_key: str """ - super(LogAnalyticsConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.customer_id = customer_id self.shared_key = shared_key -class Login(msrest.serialization.Model): +class Login(_serialization.Model): """The configuration settings of the login flow of users using ContainerApp Service Authentication/Authorization. :ivar routes: The routes that specify the endpoints used for login and logout requests. @@ -3274,21 +4547,21 @@ class Login(msrest.serialization.Model): """ _attribute_map = { - 'routes': {'key': 'routes', 'type': 'LoginRoutes'}, - 'preserve_url_fragments_for_logins': {'key': 'preserveUrlFragmentsForLogins', 'type': 'bool'}, - 'allowed_external_redirect_urls': {'key': 'allowedExternalRedirectUrls', 'type': '[str]'}, - 'cookie_expiration': {'key': 'cookieExpiration', 'type': 'CookieExpiration'}, - 'nonce': {'key': 'nonce', 'type': 'Nonce'}, + "routes": {"key": "routes", "type": "LoginRoutes"}, + "preserve_url_fragments_for_logins": {"key": "preserveUrlFragmentsForLogins", "type": "bool"}, + "allowed_external_redirect_urls": {"key": "allowedExternalRedirectUrls", "type": "[str]"}, + "cookie_expiration": {"key": "cookieExpiration", "type": "CookieExpiration"}, + "nonce": {"key": "nonce", "type": "Nonce"}, } def __init__( self, *, - routes: Optional["LoginRoutes"] = None, + routes: Optional["_models.LoginRoutes"] = None, preserve_url_fragments_for_logins: Optional[bool] = None, allowed_external_redirect_urls: Optional[List[str]] = None, - cookie_expiration: Optional["CookieExpiration"] = None, - nonce: Optional["Nonce"] = None, + cookie_expiration: Optional["_models.CookieExpiration"] = None, + nonce: Optional["_models.Nonce"] = None, **kwargs ): """ @@ -3307,7 +4580,7 @@ def __init__( :keyword nonce: The configuration settings of the nonce used in the login flow. :paramtype nonce: ~azure.mgmt.appcontainers.models.Nonce """ - super(Login, self).__init__(**kwargs) + super().__init__(**kwargs) self.routes = routes self.preserve_url_fragments_for_logins = preserve_url_fragments_for_logins self.allowed_external_redirect_urls = allowed_external_redirect_urls @@ -3315,7 +4588,7 @@ def __init__( self.nonce = nonce -class LoginRoutes(msrest.serialization.Model): +class LoginRoutes(_serialization.Model): """The routes that specify the endpoints used for login and logout requests. :ivar logout_endpoint: The endpoint at which a logout request should be made. @@ -3323,24 +4596,19 @@ class LoginRoutes(msrest.serialization.Model): """ _attribute_map = { - 'logout_endpoint': {'key': 'logoutEndpoint', 'type': 'str'}, + "logout_endpoint": {"key": "logoutEndpoint", "type": "str"}, } - def __init__( - self, - *, - logout_endpoint: Optional[str] = None, - **kwargs - ): + def __init__(self, *, logout_endpoint: Optional[str] = None, **kwargs): """ :keyword logout_endpoint: The endpoint at which a logout request should be made. :paramtype logout_endpoint: str """ - super(LoginRoutes, self).__init__(**kwargs) + super().__init__(**kwargs) self.logout_endpoint = logout_endpoint -class LoginScopes(msrest.serialization.Model): +class LoginScopes(_serialization.Model): """The configuration settings of the login flow, including the scopes that should be requested. :ivar scopes: A list of the scopes that should be requested while authenticating. @@ -3348,24 +4616,19 @@ class LoginScopes(msrest.serialization.Model): """ _attribute_map = { - 'scopes': {'key': 'scopes', 'type': '[str]'}, + "scopes": {"key": "scopes", "type": "[str]"}, } - def __init__( - self, - *, - scopes: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, scopes: Optional[List[str]] = None, **kwargs): """ :keyword scopes: A list of the scopes that should be requested while authenticating. :paramtype scopes: list[str] """ - super(LoginScopes, self).__init__(**kwargs) + super().__init__(**kwargs) self.scopes = scopes -class ManagedEnvironment(TrackedResource): +class ManagedEnvironment(TrackedResource): # pylint: disable=too-many-instance-attributes """An environment for hosting container apps. Variables are only populated by the server, and will be ignored when sending a request. @@ -3383,14 +4646,15 @@ class ManagedEnvironment(TrackedResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str - :ivar provisioning_state: Provisioning state of the Environment. Possible values include: - "Succeeded", "Failed", "Canceled", "Waiting", "InitializationInProgress", - "InfrastructureSetupInProgress", "InfrastructureSetupComplete", "ScheduledForDelete", - "UpgradeRequested", "UpgradeFailed". + :ivar sku: SKU properties of the Environment. + :vartype sku: ~azure.mgmt.appcontainers.models.EnvironmentSkuProperties + :ivar provisioning_state: Provisioning state of the Environment. Known values are: "Succeeded", + "Failed", "Canceled", "Waiting", "InitializationInProgress", "InfrastructureSetupInProgress", + "InfrastructureSetupComplete", "ScheduledForDelete", "UpgradeRequested", and "UpgradeFailed". :vartype provisioning_state: str or ~azure.mgmt.appcontainers.models.EnvironmentProvisioningState :ivar dapr_ai_instrumentation_key: Azure Monitor instrumentation key used by Dapr to export @@ -3413,36 +4677,51 @@ class ManagedEnvironment(TrackedResource): :vartype app_logs_configuration: ~azure.mgmt.appcontainers.models.AppLogsConfiguration :ivar zone_redundant: Whether or not this Managed Environment is zone-redundant. :vartype zone_redundant: bool + :ivar custom_domain_configuration: Custom domain configuration for the environment. + :vartype custom_domain_configuration: + ~azure.mgmt.appcontainers.models.CustomDomainConfiguration + :ivar event_stream_endpoint: The endpoint of the eventstream of the Environment. + :vartype event_stream_endpoint: str + :ivar workload_profiles: Workload profiles configured for the Managed Environment. + :vartype workload_profiles: list[~azure.mgmt.appcontainers.models.WorkloadProfile] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, - 'provisioning_state': {'readonly': True}, - 'deployment_errors': {'readonly': True}, - 'default_domain': {'readonly': True}, - 'static_ip': {'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'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'dapr_ai_instrumentation_key': {'key': 'properties.daprAIInstrumentationKey', 'type': 'str'}, - 'dapr_ai_connection_string': {'key': 'properties.daprAIConnectionString', 'type': 'str'}, - 'vnet_configuration': {'key': 'properties.vnetConfiguration', 'type': 'VnetConfiguration'}, - 'deployment_errors': {'key': 'properties.deploymentErrors', 'type': 'str'}, - 'default_domain': {'key': 'properties.defaultDomain', 'type': 'str'}, - 'static_ip': {'key': 'properties.staticIp', 'type': 'str'}, - 'app_logs_configuration': {'key': 'properties.appLogsConfiguration', 'type': 'AppLogsConfiguration'}, - 'zone_redundant': {'key': 'properties.zoneRedundant', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "provisioning_state": {"readonly": True}, + "deployment_errors": {"readonly": True}, + "default_domain": {"readonly": True}, + "static_ip": {"readonly": True}, + "event_stream_endpoint": {"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"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "EnvironmentSkuProperties"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "dapr_ai_instrumentation_key": {"key": "properties.daprAIInstrumentationKey", "type": "str"}, + "dapr_ai_connection_string": {"key": "properties.daprAIConnectionString", "type": "str"}, + "vnet_configuration": {"key": "properties.vnetConfiguration", "type": "VnetConfiguration"}, + "deployment_errors": {"key": "properties.deploymentErrors", "type": "str"}, + "default_domain": {"key": "properties.defaultDomain", "type": "str"}, + "static_ip": {"key": "properties.staticIp", "type": "str"}, + "app_logs_configuration": {"key": "properties.appLogsConfiguration", "type": "AppLogsConfiguration"}, + "zone_redundant": {"key": "properties.zoneRedundant", "type": "bool"}, + "custom_domain_configuration": { + "key": "properties.customDomainConfiguration", + "type": "CustomDomainConfiguration", + }, + "event_stream_endpoint": {"key": "properties.eventStreamEndpoint", "type": "str"}, + "workload_profiles": {"key": "properties.workloadProfiles", "type": "[WorkloadProfile]"}, } def __init__( @@ -3450,18 +4729,23 @@ def __init__( *, location: str, tags: Optional[Dict[str, str]] = None, + sku: Optional["_models.EnvironmentSkuProperties"] = None, dapr_ai_instrumentation_key: Optional[str] = None, dapr_ai_connection_string: Optional[str] = None, - vnet_configuration: Optional["VnetConfiguration"] = None, - app_logs_configuration: Optional["AppLogsConfiguration"] = None, + vnet_configuration: Optional["_models.VnetConfiguration"] = None, + app_logs_configuration: Optional["_models.AppLogsConfiguration"] = None, zone_redundant: Optional[bool] = None, + custom_domain_configuration: Optional["_models.CustomDomainConfiguration"] = None, + workload_profiles: Optional[List["_models.WorkloadProfile"]] = None, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str + :keyword sku: SKU properties of the Environment. + :paramtype sku: ~azure.mgmt.appcontainers.models.EnvironmentSkuProperties :keyword dapr_ai_instrumentation_key: Azure Monitor instrumentation key used by Dapr to export Service to Service communication telemetry. :paramtype dapr_ai_instrumentation_key: str @@ -3476,8 +4760,14 @@ def __init__( :paramtype app_logs_configuration: ~azure.mgmt.appcontainers.models.AppLogsConfiguration :keyword zone_redundant: Whether or not this Managed Environment is zone-redundant. :paramtype zone_redundant: bool - """ - super(ManagedEnvironment, self).__init__(tags=tags, location=location, **kwargs) + :keyword custom_domain_configuration: Custom domain configuration for the environment. + :paramtype custom_domain_configuration: + ~azure.mgmt.appcontainers.models.CustomDomainConfiguration + :keyword workload_profiles: Workload profiles configured for the Managed Environment. + :paramtype workload_profiles: list[~azure.mgmt.appcontainers.models.WorkloadProfile] + """ + super().__init__(tags=tags, location=location, **kwargs) + self.sku = sku self.provisioning_state = None self.dapr_ai_instrumentation_key = dapr_ai_instrumentation_key self.dapr_ai_connection_string = dapr_ai_connection_string @@ -3487,42 +4777,77 @@ def __init__( self.static_ip = None self.app_logs_configuration = app_logs_configuration self.zone_redundant = zone_redundant + self.custom_domain_configuration = custom_domain_configuration + self.event_stream_endpoint = None + self.workload_profiles = workload_profiles + + +class ManagedEnvironmentOutboundSettings(_serialization.Model): + """Configuration used to control the Environment Egress outbound traffic. + + :ivar out_bound_type: Outbound type for the cluster. Known values are: "LoadBalancer" and + "UserDefinedRouting". + :vartype out_bound_type: str or ~azure.mgmt.appcontainers.models.ManagedEnvironmentOutBoundType + :ivar virtual_network_appliance_ip: Virtual Appliance IP used as the Egress controller for the + Environment. + :vartype virtual_network_appliance_ip: str + """ + + _attribute_map = { + "out_bound_type": {"key": "outBoundType", "type": "str"}, + "virtual_network_appliance_ip": {"key": "virtualNetworkApplianceIp", "type": "str"}, + } + + def __init__( + self, + *, + out_bound_type: Optional[Union[str, "_models.ManagedEnvironmentOutBoundType"]] = None, + virtual_network_appliance_ip: Optional[str] = None, + **kwargs + ): + """ + :keyword out_bound_type: Outbound type for the cluster. Known values are: "LoadBalancer" and + "UserDefinedRouting". + :paramtype out_bound_type: str or + ~azure.mgmt.appcontainers.models.ManagedEnvironmentOutBoundType + :keyword virtual_network_appliance_ip: Virtual Appliance IP used as the Egress controller for + the Environment. + :paramtype virtual_network_appliance_ip: str + """ + super().__init__(**kwargs) + self.out_bound_type = out_bound_type + self.virtual_network_appliance_ip = virtual_network_appliance_ip -class ManagedEnvironmentsCollection(msrest.serialization.Model): +class ManagedEnvironmentsCollection(_serialization.Model): """Collection of Environments. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.ManagedEnvironment] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagedEnvironment]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ManagedEnvironment]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["ManagedEnvironment"], - **kwargs - ): + def __init__(self, *, value: List["_models.ManagedEnvironment"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.ManagedEnvironment] """ - super(ManagedEnvironmentsCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None @@ -3548,35 +4873,30 @@ class ManagedEnvironmentStorage(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'properties': {'key': 'properties', 'type': 'ManagedEnvironmentStorageProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "ManagedEnvironmentStorageProperties"}, } - def __init__( - self, - *, - properties: Optional["ManagedEnvironmentStorageProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.ManagedEnvironmentStorageProperties"] = None, **kwargs): """ :keyword properties: Storage properties. :paramtype properties: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorageProperties """ - super(ManagedEnvironmentStorage, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties -class ManagedEnvironmentStorageProperties(msrest.serialization.Model): +class ManagedEnvironmentStorageProperties(_serialization.Model): """Storage properties. :ivar azure_file: Azure file properties. @@ -3584,55 +4904,45 @@ class ManagedEnvironmentStorageProperties(msrest.serialization.Model): """ _attribute_map = { - 'azure_file': {'key': 'azureFile', 'type': 'AzureFileProperties'}, + "azure_file": {"key": "azureFile", "type": "AzureFileProperties"}, } - def __init__( - self, - *, - azure_file: Optional["AzureFileProperties"] = None, - **kwargs - ): + def __init__(self, *, azure_file: Optional["_models.AzureFileProperties"] = None, **kwargs): """ :keyword azure_file: Azure file properties. :paramtype azure_file: ~azure.mgmt.appcontainers.models.AzureFileProperties """ - super(ManagedEnvironmentStorageProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.azure_file = azure_file -class ManagedEnvironmentStoragesCollection(msrest.serialization.Model): +class ManagedEnvironmentStoragesCollection(_serialization.Model): """Collection of Storage for Environments. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of storage resources. + :ivar value: Collection of storage resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ManagedEnvironmentStorage]'}, + "value": {"key": "value", "type": "[ManagedEnvironmentStorage]"}, } - def __init__( - self, - *, - value: List["ManagedEnvironmentStorage"], - **kwargs - ): + def __init__(self, *, value: List["_models.ManagedEnvironmentStorage"], **kwargs): """ - :keyword value: Required. Collection of storage resources. + :keyword value: Collection of storage resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage] """ - super(ManagedEnvironmentStoragesCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ManagedServiceIdentity(msrest.serialization.Model): +class ManagedServiceIdentity(_serialization.Model): """Managed service identity (system assigned and/or user assigned identities). Variables are only populated by the server, and will be ignored when sending a request. @@ -3645,9 +4955,9 @@ class ManagedServiceIdentity(msrest.serialization.Model): :ivar tenant_id: The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. :vartype tenant_id: str - :ivar type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: Type of managed service identity (where both SystemAssigned and UserAssigned types + are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.appcontainers.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: @@ -3658,29 +4968,29 @@ class ManagedServiceIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": 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': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( self, *, - type: Union[str, "ManagedServiceIdentityType"], - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentity"]] = None, + type: Union[str, "_models.ManagedServiceIdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, **kwargs ): """ - :keyword type: Required. Type of managed service identity (where both SystemAssigned and - UserAssigned types are allowed). Possible values include: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: Type of managed service identity (where both SystemAssigned and UserAssigned + types are allowed). Required. Known values are: "None", "SystemAssigned", "UserAssigned", and + "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.appcontainers.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: @@ -3689,14 +4999,14 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.appcontainers.models.UserAssignedIdentity] """ - super(ManagedServiceIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type self.user_assigned_identities = user_assigned_identities -class Nonce(msrest.serialization.Model): +class Nonce(_serialization.Model): """The configuration settings of the nonce used in the login flow. :ivar validate_nonce: :code:`false` if the nonce should not be validated while @@ -3708,16 +5018,12 @@ class Nonce(msrest.serialization.Model): """ _attribute_map = { - 'validate_nonce': {'key': 'validateNonce', 'type': 'bool'}, - 'nonce_expiration_interval': {'key': 'nonceExpirationInterval', 'type': 'str'}, + "validate_nonce": {"key": "validateNonce", "type": "bool"}, + "nonce_expiration_interval": {"key": "nonceExpirationInterval", "type": "str"}, } def __init__( - self, - *, - validate_nonce: Optional[bool] = None, - nonce_expiration_interval: Optional[str] = None, - **kwargs + self, *, validate_nonce: Optional[bool] = None, nonce_expiration_interval: Optional[str] = None, **kwargs ): """ :keyword validate_nonce: :code:`false` if the nonce should not be validated while @@ -3727,16 +5033,16 @@ def __init__( expire. :paramtype nonce_expiration_interval: str """ - super(Nonce, self).__init__(**kwargs) + super().__init__(**kwargs) self.validate_nonce = validate_nonce self.nonce_expiration_interval = nonce_expiration_interval -class OpenIdConnectClientCredential(msrest.serialization.Model): +class OpenIdConnectClientCredential(_serialization.Model): """The authentication client credentials of the custom Open ID Connect provider. - :ivar method: The method that should be used to authenticate the user. The only acceptable - values to pass in are None and "ClientSecretPost". The default value is None. + :ivar method: The method that should be used to authenticate the user. Default value is + "ClientSecretPost". :vartype method: str :ivar client_secret_setting_name: The app setting that contains the client secret for the custom Open ID Connect provider. @@ -3744,31 +5050,25 @@ class OpenIdConnectClientCredential(msrest.serialization.Model): """ _attribute_map = { - 'method': {'key': 'method', 'type': 'str'}, - 'client_secret_setting_name': {'key': 'clientSecretSettingName', 'type': 'str'}, + "method": {"key": "method", "type": "str"}, + "client_secret_setting_name": {"key": "clientSecretSettingName", "type": "str"}, } - def __init__( - self, - *, - method: Optional[str] = None, - client_secret_setting_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, method: Optional[str] = None, client_secret_setting_name: Optional[str] = None, **kwargs): """ - :keyword method: The method that should be used to authenticate the user. The only acceptable - values to pass in are None and "ClientSecretPost". The default value is None. + :keyword method: The method that should be used to authenticate the user. Default value is + "ClientSecretPost". :paramtype method: str :keyword client_secret_setting_name: The app setting that contains the client secret for the custom Open ID Connect provider. :paramtype client_secret_setting_name: str """ - super(OpenIdConnectClientCredential, self).__init__(**kwargs) + super().__init__(**kwargs) self.method = method self.client_secret_setting_name = client_secret_setting_name -class OpenIdConnectConfig(msrest.serialization.Model): +class OpenIdConnectConfig(_serialization.Model): """The configuration settings of the endpoints used for the custom Open ID Connect provider. :ivar authorization_endpoint: The endpoint to be used to make an authorization request. @@ -3785,11 +5085,11 @@ class OpenIdConnectConfig(msrest.serialization.Model): """ _attribute_map = { - 'authorization_endpoint': {'key': 'authorizationEndpoint', 'type': 'str'}, - 'token_endpoint': {'key': 'tokenEndpoint', 'type': 'str'}, - 'issuer': {'key': 'issuer', 'type': 'str'}, - 'certification_uri': {'key': 'certificationUri', 'type': 'str'}, - 'well_known_open_id_configuration': {'key': 'wellKnownOpenIdConfiguration', 'type': 'str'}, + "authorization_endpoint": {"key": "authorizationEndpoint", "type": "str"}, + "token_endpoint": {"key": "tokenEndpoint", "type": "str"}, + "issuer": {"key": "issuer", "type": "str"}, + "certification_uri": {"key": "certificationUri", "type": "str"}, + "well_known_open_id_configuration": {"key": "wellKnownOpenIdConfiguration", "type": "str"}, } def __init__( @@ -3816,7 +5116,7 @@ def __init__( endpoints for the provider. :paramtype well_known_open_id_configuration: str """ - super(OpenIdConnectConfig, self).__init__(**kwargs) + super().__init__(**kwargs) self.authorization_endpoint = authorization_endpoint self.token_endpoint = token_endpoint self.issuer = issuer @@ -3824,7 +5124,7 @@ def __init__( self.well_known_open_id_configuration = well_known_open_id_configuration -class OpenIdConnectLogin(msrest.serialization.Model): +class OpenIdConnectLogin(_serialization.Model): """The configuration settings of the login flow of the custom Open ID Connect provider. :ivar name_claim_type: The name of the claim that contains the users name. @@ -3834,29 +5134,23 @@ class OpenIdConnectLogin(msrest.serialization.Model): """ _attribute_map = { - 'name_claim_type': {'key': 'nameClaimType', 'type': 'str'}, - 'scopes': {'key': 'scopes', 'type': '[str]'}, + "name_claim_type": {"key": "nameClaimType", "type": "str"}, + "scopes": {"key": "scopes", "type": "[str]"}, } - def __init__( - self, - *, - name_claim_type: Optional[str] = None, - scopes: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, name_claim_type: Optional[str] = None, scopes: Optional[List[str]] = None, **kwargs): """ :keyword name_claim_type: The name of the claim that contains the users name. :paramtype name_claim_type: str :keyword scopes: A list of the scopes that should be requested while authenticating. :paramtype scopes: list[str] """ - super(OpenIdConnectLogin, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_claim_type = name_claim_type self.scopes = scopes -class OpenIdConnectRegistration(msrest.serialization.Model): +class OpenIdConnectRegistration(_serialization.Model): """The configuration settings of the app registration for the custom Open ID Connect provider. :ivar client_id: The client id of the custom Open ID Connect provider. @@ -3869,17 +5163,17 @@ class OpenIdConnectRegistration(msrest.serialization.Model): """ _attribute_map = { - 'client_id': {'key': 'clientId', 'type': 'str'}, - 'client_credential': {'key': 'clientCredential', 'type': 'OpenIdConnectClientCredential'}, - 'open_id_connect_configuration': {'key': 'openIdConnectConfiguration', 'type': 'OpenIdConnectConfig'}, + "client_id": {"key": "clientId", "type": "str"}, + "client_credential": {"key": "clientCredential", "type": "OpenIdConnectClientCredential"}, + "open_id_connect_configuration": {"key": "openIdConnectConfiguration", "type": "OpenIdConnectConfig"}, } def __init__( self, *, client_id: Optional[str] = None, - client_credential: Optional["OpenIdConnectClientCredential"] = None, - open_id_connect_configuration: Optional["OpenIdConnectConfig"] = None, + client_credential: Optional["_models.OpenIdConnectClientCredential"] = None, + open_id_connect_configuration: Optional["_models.OpenIdConnectConfig"] = None, **kwargs ): """ @@ -3892,13 +5186,13 @@ def __init__( the custom Open ID Connect provider. :paramtype open_id_connect_configuration: ~azure.mgmt.appcontainers.models.OpenIdConnectConfig """ - super(OpenIdConnectRegistration, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_id = client_id self.client_credential = client_credential self.open_id_connect_configuration = open_id_connect_configuration -class OperationDetail(msrest.serialization.Model): +class OperationDetail(_serialization.Model): """Operation detail payload. :ivar name: Name of the operation. @@ -3912,10 +5206,10 @@ class OperationDetail(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, } def __init__( @@ -3923,7 +5217,7 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, **kwargs ): @@ -3937,14 +5231,14 @@ def __init__( :keyword origin: Origin of the operation. :paramtype origin: str """ - super(OperationDetail, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display self.origin = origin -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Operation display payload. :ivar provider: Resource provider of the operation. @@ -3958,10 +5252,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -3983,14 +5277,14 @@ def __init__( :keyword description: Localized friendly description for the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class QueueScaleRule(msrest.serialization.Model): +class QueueScaleRule(_serialization.Model): """Container App container Azure Queue based scaling rule. :ivar queue_name: Queue name. @@ -4002,9 +5296,9 @@ class QueueScaleRule(msrest.serialization.Model): """ _attribute_map = { - 'queue_name': {'key': 'queueName', 'type': 'str'}, - 'queue_length': {'key': 'queueLength', 'type': 'int'}, - 'auth': {'key': 'auth', 'type': '[ScaleRuleAuth]'}, + "queue_name": {"key": "queueName", "type": "str"}, + "queue_length": {"key": "queueLength", "type": "int"}, + "auth": {"key": "auth", "type": "[ScaleRuleAuth]"}, } def __init__( @@ -4012,7 +5306,7 @@ def __init__( *, queue_name: Optional[str] = None, queue_length: Optional[int] = None, - auth: Optional[List["ScaleRuleAuth"]] = None, + auth: Optional[List["_models.ScaleRuleAuth"]] = None, **kwargs ): """ @@ -4023,13 +5317,13 @@ def __init__( :keyword auth: Authentication secrets for the queue scale rule. :paramtype auth: list[~azure.mgmt.appcontainers.models.ScaleRuleAuth] """ - super(QueueScaleRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.queue_name = queue_name self.queue_length = queue_length self.auth = auth -class RegistryCredentials(msrest.serialization.Model): +class RegistryCredentials(_serialization.Model): """Container App Private Registry. :ivar server: Container Registry Server. @@ -4045,10 +5339,10 @@ class RegistryCredentials(msrest.serialization.Model): """ _attribute_map = { - 'server': {'key': 'server', 'type': 'str'}, - 'username': {'key': 'username', 'type': 'str'}, - 'password_secret_ref': {'key': 'passwordSecretRef', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'str'}, + "server": {"key": "server", "type": "str"}, + "username": {"key": "username", "type": "str"}, + "password_secret_ref": {"key": "passwordSecretRef", "type": "str"}, + "identity": {"key": "identity", "type": "str"}, } def __init__( @@ -4072,14 +5366,14 @@ def __init__( identities, use 'system'. :paramtype identity: str """ - super(RegistryCredentials, self).__init__(**kwargs) + super().__init__(**kwargs) self.server = server self.username = username self.password_secret_ref = password_secret_ref self.identity = identity -class RegistryInfo(msrest.serialization.Model): +class RegistryInfo(_serialization.Model): """Container App registry information. :ivar registry_url: registry server Url. @@ -4091,9 +5385,9 @@ class RegistryInfo(msrest.serialization.Model): """ _attribute_map = { - 'registry_url': {'key': 'registryUrl', 'type': 'str'}, - 'registry_user_name': {'key': 'registryUserName', 'type': 'str'}, - 'registry_password': {'key': 'registryPassword', 'type': 'str'}, + "registry_url": {"key": "registryUrl", "type": "str"}, + "registry_user_name": {"key": "registryUserName", "type": "str"}, + "registry_password": {"key": "registryPassword", "type": "str"}, } def __init__( @@ -4112,7 +5406,7 @@ def __init__( :keyword registry_password: registry secret. :paramtype registry_password: str """ - super(RegistryInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.registry_url = registry_url self.registry_user_name = registry_user_name self.registry_password = registry_password @@ -4141,71 +5435,63 @@ class Replica(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'created_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "created_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'created_time': {'key': 'properties.createdTime', 'type': 'iso-8601'}, - 'containers': {'key': 'properties.containers', 'type': '[ReplicaContainer]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "created_time": {"key": "properties.createdTime", "type": "iso-8601"}, + "containers": {"key": "properties.containers", "type": "[ReplicaContainer]"}, } - def __init__( - self, - *, - containers: Optional[List["ReplicaContainer"]] = None, - **kwargs - ): + def __init__(self, *, containers: Optional[List["_models.ReplicaContainer"]] = None, **kwargs): """ :keyword containers: The containers collection under a replica. :paramtype containers: list[~azure.mgmt.appcontainers.models.ReplicaContainer] """ - super(Replica, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_time = None self.containers = containers -class ReplicaCollection(msrest.serialization.Model): +class ReplicaCollection(_serialization.Model): """Container App Revision Replicas collection ARM resource. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.Replica] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Replica]'}, + "value": {"key": "value", "type": "[Replica]"}, } - def __init__( - self, - *, - value: List["Replica"], - **kwargs - ): + def __init__(self, *, value: List["_models.Replica"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.Replica] """ - super(ReplicaCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ReplicaContainer(msrest.serialization.Model): +class ReplicaContainer(_serialization.Model): """Container object under Container App Revision Replica. + Variables are only populated by the server, and will be ignored when sending a request. + :ivar name: The Name of the Container. :vartype name: str :ivar container_id: The Id of the Container. @@ -4216,14 +5502,25 @@ class ReplicaContainer(msrest.serialization.Model): :vartype started: bool :ivar restart_count: The container restart count. :vartype restart_count: int + :ivar log_stream_endpoint: Log Stream endpoint. + :vartype log_stream_endpoint: str + :ivar exec_endpoint: Container exec endpoint. + :vartype exec_endpoint: str """ + _validation = { + "log_stream_endpoint": {"readonly": True}, + "exec_endpoint": {"readonly": True}, + } + _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'container_id': {'key': 'containerId', 'type': 'str'}, - 'ready': {'key': 'ready', 'type': 'bool'}, - 'started': {'key': 'started', 'type': 'bool'}, - 'restart_count': {'key': 'restartCount', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "container_id": {"key": "containerId", "type": "str"}, + "ready": {"key": "ready", "type": "bool"}, + "started": {"key": "started", "type": "bool"}, + "restart_count": {"key": "restartCount", "type": "int"}, + "log_stream_endpoint": {"key": "logStreamEndpoint", "type": "str"}, + "exec_endpoint": {"key": "execEndpoint", "type": "str"}, } def __init__( @@ -4248,15 +5545,17 @@ def __init__( :keyword restart_count: The container restart count. :paramtype restart_count: int """ - super(ReplicaContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.container_id = container_id self.ready = ready self.started = started self.restart_count = restart_count + self.log_stream_endpoint = None + self.exec_endpoint = None -class Revision(ProxyResource): +class Revision(ProxyResource): # pylint: disable=too-many-instance-attributes """Container App Revision. Variables are only populated by the server, and will be ignored when sending a request. @@ -4275,6 +5574,9 @@ class Revision(ProxyResource): :ivar created_time: Timestamp describing when the revision was created by controller. :vartype created_time: ~datetime.datetime + :ivar last_active_time: Timestamp describing when the revision was last active. Only meaningful + when revision is inactive. + :vartype last_active_time: ~datetime.datetime :ivar fqdn: Fully qualified domain name of the revision. :vartype fqdn: str :ivar template: Container App Revision Template with all possible settings and the @@ -4289,54 +5591,53 @@ class Revision(ProxyResource): :vartype traffic_weight: int :ivar provisioning_error: Optional Field - Platform Error Message. :vartype provisioning_error: str - :ivar health_state: Current health State of the revision. Possible values include: "Healthy", - "Unhealthy", "None". + :ivar health_state: Current health State of the revision. Known values are: "Healthy", + "Unhealthy", and "None". :vartype health_state: str or ~azure.mgmt.appcontainers.models.RevisionHealthState - :ivar provisioning_state: Current provisioning State of the revision. Possible values include: - "Provisioning", "Provisioned", "Failed", "Deprovisioning", "Deprovisioned". + :ivar provisioning_state: Current provisioning State of the revision. Known values are: + "Provisioning", "Provisioned", "Failed", "Deprovisioning", and "Deprovisioned". :vartype provisioning_state: str or ~azure.mgmt.appcontainers.models.RevisionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'created_time': {'readonly': True}, - 'fqdn': {'readonly': True}, - 'template': {'readonly': True}, - 'active': {'readonly': True}, - 'replicas': {'readonly': True}, - 'traffic_weight': {'readonly': True}, - 'provisioning_error': {'readonly': True}, - 'health_state': {'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'}, - 'created_time': {'key': 'properties.createdTime', 'type': 'iso-8601'}, - 'fqdn': {'key': 'properties.fqdn', 'type': 'str'}, - 'template': {'key': 'properties.template', 'type': 'Template'}, - 'active': {'key': 'properties.active', 'type': 'bool'}, - 'replicas': {'key': 'properties.replicas', 'type': 'int'}, - 'traffic_weight': {'key': 'properties.trafficWeight', 'type': 'int'}, - 'provisioning_error': {'key': 'properties.provisioningError', 'type': 'str'}, - 'health_state': {'key': 'properties.healthState', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "created_time": {"readonly": True}, + "last_active_time": {"readonly": True}, + "fqdn": {"readonly": True}, + "template": {"readonly": True}, + "active": {"readonly": True}, + "replicas": {"readonly": True}, + "traffic_weight": {"readonly": True}, + "provisioning_error": {"readonly": True}, + "health_state": {"readonly": True}, + "provisioning_state": {"readonly": True}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Revision, self).__init__(**kwargs) + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "created_time": {"key": "properties.createdTime", "type": "iso-8601"}, + "last_active_time": {"key": "properties.lastActiveTime", "type": "iso-8601"}, + "fqdn": {"key": "properties.fqdn", "type": "str"}, + "template": {"key": "properties.template", "type": "Template"}, + "active": {"key": "properties.active", "type": "bool"}, + "replicas": {"key": "properties.replicas", "type": "int"}, + "traffic_weight": {"key": "properties.trafficWeight", "type": "int"}, + "provisioning_error": {"key": "properties.provisioningError", "type": "str"}, + "health_state": {"key": "properties.healthState", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.created_time = None + self.last_active_time = None self.fqdn = None self.template = None self.active = None @@ -4347,45 +5648,40 @@ def __init__( self.provisioning_state = None -class RevisionCollection(msrest.serialization.Model): +class RevisionCollection(_serialization.Model): """Container App Revisions collection ARM resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.Revision] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Revision]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Revision]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["Revision"], - **kwargs - ): + def __init__(self, *, value: List["_models.Revision"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.Revision] """ - super(RevisionCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class Scale(msrest.serialization.Model): +class Scale(_serialization.Model): """Container App scaling configurations. :ivar min_replicas: Optional. Minimum number of container replicas. @@ -4397,9 +5693,9 @@ class Scale(msrest.serialization.Model): """ _attribute_map = { - 'min_replicas': {'key': 'minReplicas', 'type': 'int'}, - 'max_replicas': {'key': 'maxReplicas', 'type': 'int'}, - 'rules': {'key': 'rules', 'type': '[ScaleRule]'}, + "min_replicas": {"key": "minReplicas", "type": "int"}, + "max_replicas": {"key": "maxReplicas", "type": "int"}, + "rules": {"key": "rules", "type": "[ScaleRule]"}, } def __init__( @@ -4407,7 +5703,7 @@ def __init__( *, min_replicas: Optional[int] = None, max_replicas: Optional[int] = None, - rules: Optional[List["ScaleRule"]] = None, + rules: Optional[List["_models.ScaleRule"]] = None, **kwargs ): """ @@ -4419,13 +5715,13 @@ def __init__( :keyword rules: Scaling rules. :paramtype rules: list[~azure.mgmt.appcontainers.models.ScaleRule] """ - super(Scale, self).__init__(**kwargs) + super().__init__(**kwargs) self.min_replicas = min_replicas self.max_replicas = max_replicas self.rules = rules -class ScaleRule(msrest.serialization.Model): +class ScaleRule(_serialization.Model): """Container App container scaling rule. :ivar name: Scale Rule Name. @@ -4436,22 +5732,26 @@ class ScaleRule(msrest.serialization.Model): :vartype custom: ~azure.mgmt.appcontainers.models.CustomScaleRule :ivar http: HTTP requests based scaling. :vartype http: ~azure.mgmt.appcontainers.models.HttpScaleRule + :ivar tcp: Tcp requests based scaling. + :vartype tcp: ~azure.mgmt.appcontainers.models.TcpScaleRule """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'azure_queue': {'key': 'azureQueue', 'type': 'QueueScaleRule'}, - 'custom': {'key': 'custom', 'type': 'CustomScaleRule'}, - 'http': {'key': 'http', 'type': 'HttpScaleRule'}, + "name": {"key": "name", "type": "str"}, + "azure_queue": {"key": "azureQueue", "type": "QueueScaleRule"}, + "custom": {"key": "custom", "type": "CustomScaleRule"}, + "http": {"key": "http", "type": "HttpScaleRule"}, + "tcp": {"key": "tcp", "type": "TcpScaleRule"}, } def __init__( self, *, name: Optional[str] = None, - azure_queue: Optional["QueueScaleRule"] = None, - custom: Optional["CustomScaleRule"] = None, - http: Optional["HttpScaleRule"] = None, + azure_queue: Optional["_models.QueueScaleRule"] = None, + custom: Optional["_models.CustomScaleRule"] = None, + http: Optional["_models.HttpScaleRule"] = None, + tcp: Optional["_models.TcpScaleRule"] = None, **kwargs ): """ @@ -4463,15 +5763,18 @@ def __init__( :paramtype custom: ~azure.mgmt.appcontainers.models.CustomScaleRule :keyword http: HTTP requests based scaling. :paramtype http: ~azure.mgmt.appcontainers.models.HttpScaleRule + :keyword tcp: Tcp requests based scaling. + :paramtype tcp: ~azure.mgmt.appcontainers.models.TcpScaleRule """ - super(ScaleRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.azure_queue = azure_queue self.custom = custom self.http = http + self.tcp = tcp -class ScaleRuleAuth(msrest.serialization.Model): +class ScaleRuleAuth(_serialization.Model): """Auth Secrets for Container App Scale Rule. :ivar secret_ref: Name of the Container App secret from which to pull the auth params. @@ -4481,29 +5784,23 @@ class ScaleRuleAuth(msrest.serialization.Model): """ _attribute_map = { - 'secret_ref': {'key': 'secretRef', 'type': 'str'}, - 'trigger_parameter': {'key': 'triggerParameter', 'type': 'str'}, + "secret_ref": {"key": "secretRef", "type": "str"}, + "trigger_parameter": {"key": "triggerParameter", "type": "str"}, } - def __init__( - self, - *, - secret_ref: Optional[str] = None, - trigger_parameter: Optional[str] = None, - **kwargs - ): + def __init__(self, *, secret_ref: Optional[str] = None, trigger_parameter: Optional[str] = None, **kwargs): """ :keyword secret_ref: Name of the Container App secret from which to pull the auth params. :paramtype secret_ref: str :keyword trigger_parameter: Trigger Parameter that uses the secret. :paramtype trigger_parameter: str """ - super(ScaleRuleAuth, self).__init__(**kwargs) + super().__init__(**kwargs) self.secret_ref = secret_ref self.trigger_parameter = trigger_parameter -class Secret(msrest.serialization.Model): +class Secret(_serialization.Model): """Secret definition. :ivar name: Secret Name. @@ -4513,56 +5810,45 @@ class Secret(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, value: Optional[str] = None, **kwargs): """ :keyword name: Secret Name. :paramtype name: str :keyword value: Secret Value. :paramtype value: str """ - super(Secret, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.value = value -class SecretsCollection(msrest.serialization.Model): +class SecretsCollection(_serialization.Model): """Container App Secrets Collection ARM resource. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.ContainerAppSecret] """ _validation = { - 'value': {'required': True}, + "value": {"required": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ContainerAppSecret]'}, + "value": {"key": "value", "type": "[ContainerAppSecret]"}, } - def __init__( - self, - *, - value: List["ContainerAppSecret"], - **kwargs - ): + def __init__(self, *, value: List["_models.ContainerAppSecret"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.ContainerAppSecret] """ - super(SecretsCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4582,8 +5868,8 @@ class SourceControl(ProxyResource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.appcontainers.models.SystemData - :ivar operation_state: Current provisioning State of the operation. Possible values include: - "InProgress", "Succeeded", "Failed", "Canceled". + :ivar operation_state: Current provisioning State of the operation. Known values are: + "InProgress", "Succeeded", "Failed", and "Canceled". :vartype operation_state: str or ~azure.mgmt.appcontainers.models.SourceControlOperationState :ivar repo_url: The repo url which will be integrated to ContainerApp. :vartype repo_url: str @@ -4598,22 +5884,25 @@ class SourceControl(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'operation_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "operation_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'}, - 'operation_state': {'key': 'properties.operationState', 'type': 'str'}, - 'repo_url': {'key': 'properties.repoUrl', 'type': 'str'}, - 'branch': {'key': 'properties.branch', 'type': 'str'}, - 'github_action_configuration': {'key': 'properties.githubActionConfiguration', 'type': 'GithubActionConfiguration'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "operation_state": {"key": "properties.operationState", "type": "str"}, + "repo_url": {"key": "properties.repoUrl", "type": "str"}, + "branch": {"key": "properties.branch", "type": "str"}, + "github_action_configuration": { + "key": "properties.githubActionConfiguration", + "type": "GithubActionConfiguration", + }, } def __init__( @@ -4621,7 +5910,7 @@ def __init__( *, repo_url: Optional[str] = None, branch: Optional[str] = None, - github_action_configuration: Optional["GithubActionConfiguration"] = None, + github_action_configuration: Optional["_models.GithubActionConfiguration"] = None, **kwargs ): """ @@ -4636,107 +5925,102 @@ def __init__( :paramtype github_action_configuration: ~azure.mgmt.appcontainers.models.GithubActionConfiguration """ - super(SourceControl, self).__init__(**kwargs) + super().__init__(**kwargs) self.operation_state = None self.repo_url = repo_url self.branch = branch self.github_action_configuration = github_action_configuration -class SourceControlCollection(msrest.serialization.Model): +class SourceControlCollection(_serialization.Model): """SourceControl collection ARM resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar value: Required. Collection of resources. + :ivar value: Collection of resources. Required. :vartype value: list[~azure.mgmt.appcontainers.models.SourceControl] :ivar next_link: Link to next page of resources. :vartype next_link: str """ _validation = { - 'value': {'required': True}, - 'next_link': {'readonly': True}, + "value": {"required": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SourceControl]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SourceControl]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: List["SourceControl"], - **kwargs - ): + def __init__(self, *, value: List["_models.SourceControl"], **kwargs): """ - :keyword value: Required. Collection of resources. + :keyword value: Collection of resources. Required. :paramtype value: list[~azure.mgmt.appcontainers.models.SourceControl] """ - super(SourceControlCollection, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class SystemData(msrest.serialization.Model): +class SystemData(_serialization.Model): """Metadata pertaining to creation and last modification of the resource. :ivar created_by: The identity that created the resource. :vartype created_by: str - :ivar created_by_type: The type of identity that created the resource. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.appcontainers.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.appcontainers.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.appcontainers.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.appcontainers.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -4745,40 +6029,78 @@ def __init__( self.last_modified_at = last_modified_at -class Template(msrest.serialization.Model): - """Container App versioned application definition. -Defines the desired state of an immutable revision. -Any changes to this section Will result in a new revision being created. +class TcpScaleRule(_serialization.Model): + """Container App container Tcp scaling rule. + + :ivar metadata: Metadata properties to describe tcp scale rule. + :vartype metadata: dict[str, str] + :ivar auth: Authentication secrets for the tcp scale rule. + :vartype auth: list[~azure.mgmt.appcontainers.models.ScaleRuleAuth] + """ + + _attribute_map = { + "metadata": {"key": "metadata", "type": "{str}"}, + "auth": {"key": "auth", "type": "[ScaleRuleAuth]"}, + } - :ivar revision_suffix: User friendly suffix that is appended to the revision name. - :vartype revision_suffix: str - :ivar containers: List of container definitions for the Container App. - :vartype containers: list[~azure.mgmt.appcontainers.models.Container] - :ivar scale: Scaling properties for the Container App. - :vartype scale: ~azure.mgmt.appcontainers.models.Scale - :ivar volumes: List of volume definitions for the Container App. - :vartype volumes: list[~azure.mgmt.appcontainers.models.Volume] + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + auth: Optional[List["_models.ScaleRuleAuth"]] = None, + **kwargs + ): + """ + :keyword metadata: Metadata properties to describe tcp scale rule. + :paramtype metadata: dict[str, str] + :keyword auth: Authentication secrets for the tcp scale rule. + :paramtype auth: list[~azure.mgmt.appcontainers.models.ScaleRuleAuth] + """ + super().__init__(**kwargs) + self.metadata = metadata + self.auth = auth + + +class Template(_serialization.Model): + """Container App versioned application definition. + Defines the desired state of an immutable revision. + Any changes to this section Will result in a new revision being created. + + :ivar revision_suffix: User friendly suffix that is appended to the revision name. + :vartype revision_suffix: str + :ivar init_containers: List of specialized containers that run before app containers. + :vartype init_containers: list[~azure.mgmt.appcontainers.models.InitContainer] + :ivar containers: List of container definitions for the Container App. + :vartype containers: list[~azure.mgmt.appcontainers.models.Container] + :ivar scale: Scaling properties for the Container App. + :vartype scale: ~azure.mgmt.appcontainers.models.Scale + :ivar volumes: List of volume definitions for the Container App. + :vartype volumes: list[~azure.mgmt.appcontainers.models.Volume] """ _attribute_map = { - 'revision_suffix': {'key': 'revisionSuffix', 'type': 'str'}, - 'containers': {'key': 'containers', 'type': '[Container]'}, - 'scale': {'key': 'scale', 'type': 'Scale'}, - 'volumes': {'key': 'volumes', 'type': '[Volume]'}, + "revision_suffix": {"key": "revisionSuffix", "type": "str"}, + "init_containers": {"key": "initContainers", "type": "[InitContainer]"}, + "containers": {"key": "containers", "type": "[Container]"}, + "scale": {"key": "scale", "type": "Scale"}, + "volumes": {"key": "volumes", "type": "[Volume]"}, } def __init__( self, *, revision_suffix: Optional[str] = None, - containers: Optional[List["Container"]] = None, - scale: Optional["Scale"] = None, - volumes: Optional[List["Volume"]] = None, + init_containers: Optional[List["_models.InitContainer"]] = None, + containers: Optional[List["_models.Container"]] = None, + scale: Optional["_models.Scale"] = None, + volumes: Optional[List["_models.Volume"]] = None, **kwargs ): """ :keyword revision_suffix: User friendly suffix that is appended to the revision name. :paramtype revision_suffix: str + :keyword init_containers: List of specialized containers that run before app containers. + :paramtype init_containers: list[~azure.mgmt.appcontainers.models.InitContainer] :keyword containers: List of container definitions for the Container App. :paramtype containers: list[~azure.mgmt.appcontainers.models.Container] :keyword scale: Scaling properties for the Container App. @@ -4786,14 +6108,15 @@ def __init__( :keyword volumes: List of volume definitions for the Container App. :paramtype volumes: list[~azure.mgmt.appcontainers.models.Volume] """ - super(Template, self).__init__(**kwargs) + super().__init__(**kwargs) self.revision_suffix = revision_suffix + self.init_containers = init_containers self.containers = containers self.scale = scale self.volumes = volumes -class TrafficWeight(msrest.serialization.Model): +class TrafficWeight(_serialization.Model): """Traffic weight assigned to a revision. :ivar revision_name: Name of a revision. @@ -4807,10 +6130,10 @@ class TrafficWeight(msrest.serialization.Model): """ _attribute_map = { - 'revision_name': {'key': 'revisionName', 'type': 'str'}, - 'weight': {'key': 'weight', 'type': 'int'}, - 'latest_revision': {'key': 'latestRevision', 'type': 'bool'}, - 'label': {'key': 'label', 'type': 'str'}, + "revision_name": {"key": "revisionName", "type": "str"}, + "weight": {"key": "weight", "type": "int"}, + "latest_revision": {"key": "latestRevision", "type": "bool"}, + "label": {"key": "label", "type": "str"}, } def __init__( @@ -4818,7 +6141,7 @@ def __init__( *, revision_name: Optional[str] = None, weight: Optional[int] = None, - latest_revision: Optional[bool] = False, + latest_revision: bool = False, label: Optional[str] = None, **kwargs ): @@ -4833,14 +6156,14 @@ def __init__( :keyword label: Associates a traffic label with a revision. :paramtype label: str """ - super(TrafficWeight, self).__init__(**kwargs) + super().__init__(**kwargs) self.revision_name = revision_name self.weight = weight self.latest_revision = latest_revision self.label = label -class Twitter(msrest.serialization.Model): +class Twitter(_serialization.Model): """The configuration settings of the Twitter provider. :ivar enabled: :code:`false` if the Twitter provider should not be enabled despite @@ -4852,16 +6175,12 @@ class Twitter(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'registration': {'key': 'registration', 'type': 'TwitterRegistration'}, + "enabled": {"key": "enabled", "type": "bool"}, + "registration": {"key": "registration", "type": "TwitterRegistration"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - registration: Optional["TwitterRegistration"] = None, - **kwargs + self, *, enabled: Optional[bool] = None, registration: Optional["_models.TwitterRegistration"] = None, **kwargs ): """ :keyword enabled: :code:`false` if the Twitter provider should not be enabled @@ -4871,12 +6190,12 @@ def __init__( provider. :paramtype registration: ~azure.mgmt.appcontainers.models.TwitterRegistration """ - super(Twitter, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.registration = registration -class TwitterRegistration(msrest.serialization.Model): +class TwitterRegistration(_serialization.Model): """The configuration settings of the app registration for the Twitter provider. :ivar consumer_key: The OAuth 1.0a consumer key of the Twitter application used for sign-in. @@ -4890,16 +6209,12 @@ class TwitterRegistration(msrest.serialization.Model): """ _attribute_map = { - 'consumer_key': {'key': 'consumerKey', 'type': 'str'}, - 'consumer_secret_setting_name': {'key': 'consumerSecretSettingName', 'type': 'str'}, + "consumer_key": {"key": "consumerKey", "type": "str"}, + "consumer_secret_setting_name": {"key": "consumerSecretSettingName", "type": "str"}, } def __init__( - self, - *, - consumer_key: Optional[str] = None, - consumer_secret_setting_name: Optional[str] = None, - **kwargs + self, *, consumer_key: Optional[str] = None, consumer_secret_setting_name: Optional[str] = None, **kwargs ): """ :keyword consumer_key: The OAuth 1.0a consumer key of the Twitter application used for sign-in. @@ -4911,12 +6226,12 @@ def __init__( application used for sign-in. :paramtype consumer_secret_setting_name: str """ - super(TwitterRegistration, self).__init__(**kwargs) + super().__init__(**kwargs) self.consumer_key = consumer_key self.consumer_secret_setting_name = consumer_secret_setting_name -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """User assigned identity properties. Variables are only populated by the server, and will be ignored when sending a request. @@ -4928,32 +6243,28 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VnetConfiguration(msrest.serialization.Model): +class VnetConfiguration(_serialization.Model): """Configuration properties for apps environment to join a Virtual Network. :ivar internal: Boolean indicating the environment only has an internal load balancer. These - environments do not have a public static IP resource, must provide ControlPlaneSubnetResourceId - and AppSubnetResourceId if enabling this property. + environments do not have a public static IP resource. They must provide runtimeSubnetId and + infrastructureSubnetId if enabling this property. :vartype internal: bool :ivar infrastructure_subnet_id: Resource ID of a subnet for infrastructure components. This subnet must be in the same VNET as the subnet defined in runtimeSubnetId. Must not overlap with @@ -4972,15 +6283,18 @@ class VnetConfiguration(msrest.serialization.Model): :ivar platform_reserved_dns_ip: An IP address from the IP range defined by platformReservedCidr that will be reserved for the internal DNS server. :vartype platform_reserved_dns_ip: str + :ivar outbound_settings: Configuration used to control the Environment Egress outbound traffic. + :vartype outbound_settings: ~azure.mgmt.appcontainers.models.ManagedEnvironmentOutboundSettings """ _attribute_map = { - 'internal': {'key': 'internal', 'type': 'bool'}, - 'infrastructure_subnet_id': {'key': 'infrastructureSubnetId', 'type': 'str'}, - 'runtime_subnet_id': {'key': 'runtimeSubnetId', 'type': 'str'}, - 'docker_bridge_cidr': {'key': 'dockerBridgeCidr', 'type': 'str'}, - 'platform_reserved_cidr': {'key': 'platformReservedCidr', 'type': 'str'}, - 'platform_reserved_dns_ip': {'key': 'platformReservedDnsIP', 'type': 'str'}, + "internal": {"key": "internal", "type": "bool"}, + "infrastructure_subnet_id": {"key": "infrastructureSubnetId", "type": "str"}, + "runtime_subnet_id": {"key": "runtimeSubnetId", "type": "str"}, + "docker_bridge_cidr": {"key": "dockerBridgeCidr", "type": "str"}, + "platform_reserved_cidr": {"key": "platformReservedCidr", "type": "str"}, + "platform_reserved_dns_ip": {"key": "platformReservedDnsIP", "type": "str"}, + "outbound_settings": {"key": "outboundSettings", "type": "ManagedEnvironmentOutboundSettings"}, } def __init__( @@ -4992,12 +6306,13 @@ def __init__( docker_bridge_cidr: Optional[str] = None, platform_reserved_cidr: Optional[str] = None, platform_reserved_dns_ip: Optional[str] = None, + outbound_settings: Optional["_models.ManagedEnvironmentOutboundSettings"] = None, **kwargs ): """ :keyword internal: Boolean indicating the environment only has an internal load balancer. These - environments do not have a public static IP resource, must provide ControlPlaneSubnetResourceId - and AppSubnetResourceId if enabling this property. + environments do not have a public static IP resource. They must provide runtimeSubnetId and + infrastructureSubnetId if enabling this property. :paramtype internal: bool :keyword infrastructure_subnet_id: Resource ID of a subnet for infrastructure components. This subnet must be in the same VNET as the subnet defined in runtimeSubnetId. Must not overlap with @@ -5016,58 +6331,63 @@ def __init__( :keyword platform_reserved_dns_ip: An IP address from the IP range defined by platformReservedCidr that will be reserved for the internal DNS server. :paramtype platform_reserved_dns_ip: str + :keyword outbound_settings: Configuration used to control the Environment Egress outbound + traffic. + :paramtype outbound_settings: + ~azure.mgmt.appcontainers.models.ManagedEnvironmentOutboundSettings """ - super(VnetConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.internal = internal self.infrastructure_subnet_id = infrastructure_subnet_id self.runtime_subnet_id = runtime_subnet_id self.docker_bridge_cidr = docker_bridge_cidr self.platform_reserved_cidr = platform_reserved_cidr self.platform_reserved_dns_ip = platform_reserved_dns_ip + self.outbound_settings = outbound_settings -class Volume(msrest.serialization.Model): +class Volume(_serialization.Model): """Volume definitions for the Container App. :ivar name: Volume name. :vartype name: str - :ivar storage_type: Storage type for the volume. If not provided, use EmptyDir. Possible values - include: "AzureFile", "EmptyDir". + :ivar storage_type: Storage type for the volume. If not provided, use EmptyDir. Known values + are: "AzureFile" and "EmptyDir". :vartype storage_type: str or ~azure.mgmt.appcontainers.models.StorageType :ivar storage_name: Name of storage resource. No need to provide for EmptyDir. :vartype storage_name: str """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'storage_type': {'key': 'storageType', 'type': 'str'}, - 'storage_name': {'key': 'storageName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "storage_type": {"key": "storageType", "type": "str"}, + "storage_name": {"key": "storageName", "type": "str"}, } def __init__( self, *, name: Optional[str] = None, - storage_type: Optional[Union[str, "StorageType"]] = None, + storage_type: Optional[Union[str, "_models.StorageType"]] = None, storage_name: Optional[str] = None, **kwargs ): """ :keyword name: Volume name. :paramtype name: str - :keyword storage_type: Storage type for the volume. If not provided, use EmptyDir. Possible - values include: "AzureFile", "EmptyDir". + :keyword storage_type: Storage type for the volume. If not provided, use EmptyDir. Known values + are: "AzureFile" and "EmptyDir". :paramtype storage_type: str or ~azure.mgmt.appcontainers.models.StorageType :keyword storage_name: Name of storage resource. No need to provide for EmptyDir. :paramtype storage_name: str """ - super(Volume, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.storage_type = storage_type self.storage_name = storage_name -class VolumeMount(msrest.serialization.Model): +class VolumeMount(_serialization.Model): """Volume mount for the Container App. :ivar volume_name: This must match the Name of a Volume. @@ -5078,17 +6398,11 @@ class VolumeMount(msrest.serialization.Model): """ _attribute_map = { - 'volume_name': {'key': 'volumeName', 'type': 'str'}, - 'mount_path': {'key': 'mountPath', 'type': 'str'}, + "volume_name": {"key": "volumeName", "type": "str"}, + "mount_path": {"key": "mountPath", "type": "str"}, } - def __init__( - self, - *, - volume_name: Optional[str] = None, - mount_path: Optional[str] = None, - **kwargs - ): + def __init__(self, *, volume_name: Optional[str] = None, mount_path: Optional[str] = None, **kwargs): """ :keyword volume_name: This must match the Name of a Volume. :paramtype volume_name: str @@ -5096,6 +6410,46 @@ def __init__( contain ':'. :paramtype mount_path: str """ - super(VolumeMount, self).__init__(**kwargs) + super().__init__(**kwargs) self.volume_name = volume_name self.mount_path = mount_path + + +class WorkloadProfile(_serialization.Model): + """Workload profile to scope container app execution. + + All required parameters must be populated in order to send to Azure. + + :ivar workload_profile_type: Workload profile type for the workloads to run on. Required. + :vartype workload_profile_type: str + :ivar minimum_count: The minimum capacity. Required. + :vartype minimum_count: int + :ivar maximum_count: The maximum capacity. Required. + :vartype maximum_count: int + """ + + _validation = { + "workload_profile_type": {"required": True}, + "minimum_count": {"required": True}, + "maximum_count": {"required": True}, + } + + _attribute_map = { + "workload_profile_type": {"key": "workloadProfileType", "type": "str"}, + "minimum_count": {"key": "minimumCount", "type": "int"}, + "maximum_count": {"key": "maximumCount", "type": "int"}, + } + + def __init__(self, *, workload_profile_type: str, minimum_count: int, maximum_count: int, **kwargs): + """ + :keyword workload_profile_type: Workload profile type for the workloads to run on. Required. + :paramtype workload_profile_type: str + :keyword minimum_count: The minimum capacity. Required. + :paramtype minimum_count: int + :keyword maximum_count: The maximum capacity. Required. + :paramtype maximum_count: int + """ + super().__init__(**kwargs) + self.workload_profile_type = workload_profile_type + self.minimum_count = minimum_count + self.maximum_count = maximum_count diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_patch.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/__init__.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/__init__.py index 505be253220b7..38342a997743c 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/__init__.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/__init__.py @@ -11,23 +11,45 @@ from ._container_apps_revisions_operations import ContainerAppsRevisionsOperations from ._container_apps_revision_replicas_operations import ContainerAppsRevisionReplicasOperations from ._dapr_components_operations import DaprComponentsOperations +from ._container_apps_diagnostics_operations import ContainerAppsDiagnosticsOperations +from ._managed_environment_diagnostics_operations import ManagedEnvironmentDiagnosticsOperations +from ._managed_environments_diagnostics_operations import ManagedEnvironmentsDiagnosticsOperations from ._operations import Operations from ._managed_environments_operations import ManagedEnvironmentsOperations from ._certificates_operations import CertificatesOperations from ._namespaces_operations import NamespacesOperations from ._managed_environments_storages_operations import ManagedEnvironmentsStoragesOperations from ._container_apps_source_controls_operations import ContainerAppsSourceControlsOperations +from ._connected_environments_operations import ConnectedEnvironmentsOperations +from ._connected_environments_certificates_operations import ConnectedEnvironmentsCertificatesOperations +from ._connected_environments_dapr_components_operations import ConnectedEnvironmentsDaprComponentsOperations +from ._connected_environments_storages_operations import ConnectedEnvironmentsStoragesOperations +from ._billing_meters_operations import BillingMetersOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'ContainerAppsAuthConfigsOperations', - 'ContainerAppsOperations', - 'ContainerAppsRevisionsOperations', - 'ContainerAppsRevisionReplicasOperations', - 'DaprComponentsOperations', - 'Operations', - 'ManagedEnvironmentsOperations', - 'CertificatesOperations', - 'NamespacesOperations', - 'ManagedEnvironmentsStoragesOperations', - 'ContainerAppsSourceControlsOperations', + "ContainerAppsAuthConfigsOperations", + "ContainerAppsOperations", + "ContainerAppsRevisionsOperations", + "ContainerAppsRevisionReplicasOperations", + "DaprComponentsOperations", + "ContainerAppsDiagnosticsOperations", + "ManagedEnvironmentDiagnosticsOperations", + "ManagedEnvironmentsDiagnosticsOperations", + "Operations", + "ManagedEnvironmentsOperations", + "CertificatesOperations", + "NamespacesOperations", + "ManagedEnvironmentsStoragesOperations", + "ContainerAppsSourceControlsOperations", + "ConnectedEnvironmentsOperations", + "ConnectedEnvironmentsCertificatesOperations", + "ConnectedEnvironmentsDaprComponentsOperations", + "ConnectedEnvironmentsStoragesOperations", + "BillingMetersOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_billing_meters_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_billing_meters_operations.py new file mode 100644 index 0000000000000..f144e6ff3c3cd --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_billing_meters_operations.py @@ -0,0 +1,139 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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(location: str, subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.App/locations/{location}/billingMeters" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BillingMetersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`billing_meters` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, location: str, **kwargs: Any) -> _models.BillingMeterCollection: + """Get billing meters by location. + + Get all billingMeters for a location. + + :param location: The name of Azure region. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BillingMeterCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.BillingMeterCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.BillingMeterCollection] + + request = build_get_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BillingMeterCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/locations/{location}/billingMeters"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_certificates_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_certificates_operations.py index cb582da44c7d8..6928df5b4526f 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_certificates_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_certificates_operations.py @@ -6,304 +6,283 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - certificate_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, environment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - certificate_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, environment_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class CertificatesOperations(object): - """CertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class CertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> Iterable["_models.CertificateCollection"]: + def list(self, resource_group_name: str, environment_name: str, **kwargs: Any) -> Iterable["_models.Certificate"]: """Get the Certificates in a given managed environment. Get the Certificates in a given managed environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CertificateCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.CertificateCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Certificate or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.Certificate] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - environment_name=environment_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -317,10 +296,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -331,60 +308,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - environment_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.Certificate": + self, resource_group_name: str, environment_name: str, certificate_name: str, **kwargs: Any + ) -> _models.Certificate: """Get the specified Certificate. Get the specified Certificate. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Certificate, or the result of cls(response) + :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Certificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -392,74 +370,158 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Certificate', pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, environment_name: str, certificate_name: str, - certificate_envelope: Optional["_models.Certificate"] = None, + certificate_envelope: Optional[_models.Certificate] = None, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Create or Update a Certificate. Create or Update a Certificate. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str :param certificate_envelope: Certificate to be created or updated. Default value is None. :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Default value is None. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Certificate, or the result of cls(response) + :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Certificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: Optional[Union[_models.Certificate, IO]] = None, + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Is either a model type or a + IO type. Default value is None. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] - if certificate_envelope is not None: - _json = self._serialize.body(certificate_envelope, 'Certificate') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope else: - _json = None + if certificate_envelope is not None: + _json = self._serialize.body(certificate_envelope, "Certificate") + else: + _json = None request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -467,64 +529,66 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Certificate', pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - certificate_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, certificate_name: str, **kwargs: Any ) -> None: """Deletes the specified Certificate. Deletes the specified Certificate. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -535,8 +599,73 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: _models.CertificatePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + environment_name: str, + certificate_name: str, + certificate_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -544,55 +673,74 @@ def update( resource_group_name: str, environment_name: str, certificate_name: str, - certificate_envelope: "_models.CertificatePatch", + certificate_envelope: Union[_models.CertificatePatch, IO], **kwargs: Any - ) -> "_models.Certificate": + ) -> _models.Certificate: """Update properties of a certificate. Patches a certificate. Currently only patching of tags is supported. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param certificate_name: Name of the Certificate. + :param certificate_name: Name of the Certificate. Required. :type certificate_name: str - :param certificate_envelope: Properties of a certificate that need to be updated. - :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch + :param certificate_envelope: Properties of a certificate that need to be updated. Is either a + model type or a IO type. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Certificate, or the result of cls(response) + :return: Certificate or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Certificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Certificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(certificate_envelope, 'CertificatePatch') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope + else: + _json = self._serialize.body(certificate_envelope, "CertificatePatch") request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -600,12 +748,11 @@ def update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Certificate', pipeline_response) + deserialized = self._deserialize("Certificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/certificates/{certificateName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_certificates_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_certificates_operations.py new file mode 100644 index 0000000000000..d6f97acf78438 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_certificates_operations.py @@ -0,0 +1,776 @@ +# 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 typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConnectedEnvironmentsCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`connected_environments_certificates` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> Iterable["_models.Certificate"]: + """Get the Certificates in a given connected environment. + + Get the Certificates in a given connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Certificate or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.Certificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("CertificateCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, connected_environment_name: str, certificate_name: str, **kwargs: Any + ) -> _models.Certificate: + """Get the specified Certificate. + + Get the specified Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Certificate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Optional[_models.Certificate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Default value is None. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Default value is None. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Optional[Union[_models.Certificate, IO]] = None, + **kwargs: Any + ) -> _models.Certificate: + """Create or Update a Certificate. + + Create or Update a Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Certificate to be created or updated. Is either a model type or a + IO type. Default value is None. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.Certificate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope + else: + if certificate_envelope is not None: + _json = self._serialize.body(certificate_envelope, "Certificate") + else: + _json = None + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Certificate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, certificate_name: str, **kwargs: Any + ) -> None: + """Deletes the specified Certificate. + + Deletes the specified Certificate. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: _models.CertificatePatch, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Required. + :type certificate_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + connected_environment_name: str, + certificate_name: str, + certificate_envelope: Union[_models.CertificatePatch, IO], + **kwargs: Any + ) -> _models.Certificate: + """Update properties of a certificate. + + Patches a certificate. Currently only patching of tags is supported. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Connected Environment. Required. + :type connected_environment_name: str + :param certificate_name: Name of the Certificate. Required. + :type certificate_name: str + :param certificate_envelope: Properties of a certificate that need to be updated. Is either a + model type or a IO type. Required. + :type certificate_envelope: ~azure.mgmt.appcontainers.models.CertificatePatch or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Certificate or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Certificate + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Certificate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_envelope, (IO, bytes)): + _content = certificate_envelope + else: + _json = self._serialize.body(certificate_envelope, "CertificatePatch") + + request = build_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Certificate", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/certificates/{certificateName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_dapr_components_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_dapr_components_operations.py new file mode 100644 index 0000000000000..779feac1797e4 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_dapr_components_operations.py @@ -0,0 +1,665 @@ +# 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 typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, connected_environment_name: str, component_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, connected_environment_name: str, component_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, connected_environment_name: str, component_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_secrets_request( + resource_group_name: str, connected_environment_name: str, component_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}/listSecrets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConnectedEnvironmentsDaprComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`connected_environments_dapr_components` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> Iterable["_models.DaprComponent"]: + """Get the Dapr Components for a connected environment. + + Get the Dapr Components for a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DaprComponent or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.DaprComponent] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponentsCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DaprComponentsCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, connected_environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprComponent: + """Get a dapr component. + + Get a dapr component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DaprComponent", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + component_name: str, + dapr_component_envelope: _models.DaprComponent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + component_name: str, + dapr_component_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + component_name: str, + dapr_component_envelope: Union[_models.DaprComponent, IO], + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Is either a model + type or a IO type. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dapr_component_envelope, (IO, bytes)): + _content = dapr_component_envelope + else: + _json = self._serialize.body(dapr_component_envelope, "DaprComponent") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DaprComponent", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, component_name: str, **kwargs: Any + ) -> None: + """Delete a Dapr Component. + + Delete a Dapr Component from a connected environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}"} # type: ignore + + @distributed_trace + def list_secrets( + self, resource_group_name: str, connected_environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprSecretsCollection: + """List secrets for a dapr component. + + List secrets for a dapr component. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connected environment. Required. + :type connected_environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprSecretsCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprSecretsCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprSecretsCollection] + + request = build_list_secrets_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + component_name=component_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DaprSecretsCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/daprComponents/{componentName}/listSecrets"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_operations.py new file mode 100644 index 0000000000000..f509dd34c3bec --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_operations.py @@ -0,0 +1,1045 @@ +# 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 typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.App/connectedEnvironments") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_check_name_availability_request( + resource_group_name: str, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/checkNameAvailability", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConnectedEnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`connected_environments` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ConnectedEnvironment"]: + """Get all connectedEnvironments for a subscription. + + Get all connectedEnvironments for a subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedEnvironment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedEnvironmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/connectedEnvironments"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ConnectedEnvironment"]: + """Get all connectedEnvironments in a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ConnectedEnvironment or the result of + cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ConnectedEnvironmentCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironment: + """Get the properties of an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironment or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: Union[_models.ConnectedEnvironment, IO], + **kwargs: Any + ) -> _models.ConnectedEnvironment: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(environment_envelope, (IO, bytes)): + _content = environment_envelope + else: + _json = self._serialize.body(environment_envelope, "ConnectedEnvironment") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: _models.ConnectedEnvironment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedEnvironment]: + """Creates or updates an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :param environment_envelope: Configuration details of the connectedEnvironment. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConnectedEnvironment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ConnectedEnvironment]: + """Creates or updates an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :param environment_envelope: Configuration details of the connectedEnvironment. Required. + :type environment_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConnectedEnvironment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + environment_envelope: Union[_models.ConnectedEnvironment, IO], + **kwargs: Any + ) -> LROPoller[_models.ConnectedEnvironment]: + """Creates or updates an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :param environment_envelope: Configuration details of the connectedEnvironment. Is either a + model type or a IO type. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ConnectedEnvironment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ConnectedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( # type: ignore + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + environment_envelope=environment_envelope, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @distributed_trace + def begin_delete(self, resource_group_name: str, connected_environment_name: str, **kwargs: Any) -> LROPoller[None]: + """Delete an connectedEnvironment. + + Delete an connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @distributed_trace + def update( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironment: + """Update connected Environment's properties. + + Patches a Managed Environment. Only patching of tags is supported currently. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the connectedEnvironment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironment or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironment] + + request = build_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}"} # type: ignore + + @overload + def check_name_availability( + self, + resource_group_name: str, + connected_environment_name: str, + check_name_availability_request: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource connectedEnvironmentName availability. + + Checks if resource connectedEnvironmentName is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Managed Environment. Required. + :type connected_environment_name: str + :param check_name_availability_request: The check connectedEnvironmentName availability + request. Required. + :type check_name_availability_request: + ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + connected_environment_name: str, + check_name_availability_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource connectedEnvironmentName availability. + + Checks if resource connectedEnvironmentName is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Managed Environment. Required. + :type connected_environment_name: str + :param check_name_availability_request: The check connectedEnvironmentName availability + request. Required. + :type check_name_availability_request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + connected_environment_name: str, + check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource connectedEnvironmentName availability. + + Checks if resource connectedEnvironmentName is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Managed Environment. Required. + :type connected_environment_name: str + :param check_name_availability_request: The check connectedEnvironmentName availability + request. Is either a model type or a IO type. Required. + :type check_name_availability_request: + ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_request, (IO, bytes)): + _content = check_name_availability_request + else: + _json = self._serialize.body(check_name_availability_request, "CheckNameAvailabilityRequest") + + request = build_check_name_availability_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/checkNameAvailability"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_storages_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_storages_operations.py new file mode 100644 index 0000000000000..71704372352f7 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_connected_environments_storages_operations.py @@ -0,0 +1,542 @@ +# 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 typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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, connected_environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, connected_environment_name: str, storage_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "storageName": _SERIALIZER.url("storage_name", storage_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, connected_environment_name: str, storage_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "storageName": _SERIALIZER.url("storage_name", storage_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, connected_environment_name: str, storage_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "connectedEnvironmentName": _SERIALIZER.url("connected_environment_name", connected_environment_name, "str"), + "storageName": _SERIALIZER.url("storage_name", storage_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ConnectedEnvironmentsStoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`connected_environments_storages` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list( + self, resource_group_name: str, connected_environment_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironmentStoragesCollection: + """Get all storages for a connectedEnvironment. + + Get all storages for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStoragesCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStoragesCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentStoragesCollection] + + request = build_list_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironmentStoragesCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, connected_environment_name: str, storage_name: str, **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Get storage for a connectedEnvironment. + + Get storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentStorage] + + request = build_get_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + storage_name=storage_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironmentStorage", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + storage_name: str, + storage_envelope: _models.ConnectedEnvironmentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Create or update storage for a connectedEnvironment. + + Create or update storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + storage_name: str, + storage_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Create or update storage for a connectedEnvironment. + + Create or update storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + connected_environment_name: str, + storage_name: str, + storage_envelope: Union[_models.ConnectedEnvironmentStorage, IO], + **kwargs: Any + ) -> _models.ConnectedEnvironmentStorage: + """Create or update storage for a connectedEnvironment. + + Create or update storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Is either a model type or a IO type. + Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ConnectedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ConnectedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectedEnvironmentStorage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_envelope, (IO, bytes)): + _content = storage_envelope + else: + _json = self._serialize.body(storage_envelope, "ConnectedEnvironmentStorage") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + storage_name=storage_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ConnectedEnvironmentStorage", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, connected_environment_name: str, storage_name: str, **kwargs: Any + ) -> None: + """Delete storage for a connectedEnvironment. + + Delete storage for a connectedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param connected_environment_name: Name of the Environment. Required. + :type connected_environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + connected_environment_name=connected_environment_name, + storage_name=storage_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/connectedEnvironments/{connectedEnvironmentName}/storages/{storageName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_auth_configs_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_auth_configs_operations.py index b781f9a33621c..7f6395b291b55 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_auth_configs_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_auth_configs_operations.py @@ -6,258 +6,248 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_container_app_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - auth_config_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, auth_config_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "authConfigName": _SERIALIZER.url("auth_config_name", auth_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "authConfigName": _SERIALIZER.url("auth_config_name", auth_config_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - auth_config_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, container_app_name: str, auth_config_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "authConfigName": _SERIALIZER.url("auth_config_name", auth_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "authConfigName": _SERIALIZER.url("auth_config_name", auth_config_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - auth_config_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, auth_config_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "authConfigName": _SERIALIZER.url("auth_config_name", auth_config_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "authConfigName": _SERIALIZER.url("auth_config_name", auth_config_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ContainerAppsAuthConfigsOperations(object): - """ContainerAppsAuthConfigsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerAppsAuthConfigsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`container_apps_auth_configs` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_container_app( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> Iterable["_models.AuthConfigCollection"]: + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> Iterable["_models.AuthConfig"]: """Get the Container App AuthConfigs in a given resource group. Get the Container App AuthConfigs in a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AuthConfigCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.AuthConfigCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either AuthConfig or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.AuthConfig] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthConfigCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthConfigCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_container_app.metadata['url'], + template_url=self.list_by_container_app.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - container_app_name=container_app_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -271,10 +261,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -285,60 +273,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_container_app.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs"} # type: ignore + list_by_container_app.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - container_app_name: str, - auth_config_name: str, - **kwargs: Any - ) -> "_models.AuthConfig": + self, resource_group_name: str, container_app_name: str, auth_config_name: str, **kwargs: Any + ) -> _models.AuthConfig: """Get a AuthConfig of a Container App. Get a AuthConfig of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param auth_config_name: Name of the Container App AuthConfig. + :param auth_config_name: Name of the Container App AuthConfig. Required. :type auth_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthConfig, or the result of cls(response) + :return: AuthConfig or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.AuthConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthConfig] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, auth_config_name=auth_config_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -346,15 +335,80 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthConfig', pipeline_response) + deserialized = self._deserialize("AuthConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + container_app_name: str, + auth_config_name: str, + auth_config_envelope: _models.AuthConfig, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthConfig: + """Create or update the AuthConfig for a Container App. + + Create or update the AuthConfig for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param auth_config_name: Name of the Container App AuthConfig. Required. + :type auth_config_name: str + :param auth_config_envelope: Properties used to create a Container App AuthConfig. Required. + :type auth_config_envelope: ~azure.mgmt.appcontainers.models.AuthConfig + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthConfig or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.AuthConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + container_app_name: str, + auth_config_name: str, + auth_config_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AuthConfig: + """Create or update the AuthConfig for a Container App. + Create or update the AuthConfig for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param auth_config_name: Name of the Container App AuthConfig. Required. + :type auth_config_name: str + :param auth_config_envelope: Properties used to create a Container App AuthConfig. Required. + :type auth_config_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: AuthConfig or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.AuthConfig + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -362,55 +416,74 @@ def create_or_update( resource_group_name: str, container_app_name: str, auth_config_name: str, - auth_config_envelope: "_models.AuthConfig", + auth_config_envelope: Union[_models.AuthConfig, IO], **kwargs: Any - ) -> "_models.AuthConfig": + ) -> _models.AuthConfig: """Create or update the AuthConfig for a Container App. - Description for Create or update the AuthConfig for a Container App. + Create or update the AuthConfig for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param auth_config_name: Name of the Container App AuthConfig. + :param auth_config_name: Name of the Container App AuthConfig. Required. :type auth_config_name: str - :param auth_config_envelope: Properties used to create a Container App AuthConfig. - :type auth_config_envelope: ~azure.mgmt.appcontainers.models.AuthConfig + :param auth_config_envelope: Properties used to create a Container App AuthConfig. Is either a + model type or a IO type. Required. + :type auth_config_envelope: ~azure.mgmt.appcontainers.models.AuthConfig or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AuthConfig, or the result of cls(response) + :return: AuthConfig or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.AuthConfig - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AuthConfig"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AuthConfig] - _json = self._serialize.body(auth_config_envelope, 'AuthConfig') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(auth_config_envelope, (IO, bytes)): + _content = auth_config_envelope + else: + _json = self._serialize.body(auth_config_envelope, "AuthConfig") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, auth_config_name=auth_config_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,64 +491,66 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AuthConfig', pipeline_response) + deserialized = self._deserialize("AuthConfig", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - auth_config_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, auth_config_name: str, **kwargs: Any ) -> None: """Delete a Container App AuthConfig. - Description for Delete a Container App AuthConfig. + Delete a Container App AuthConfig. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param auth_config_name: Name of the Container App AuthConfig. + :param auth_config_name: Name of the Container App AuthConfig. Required. :type auth_config_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, auth_config_name=auth_config_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -486,5 +561,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/authConfigs/{authConfigName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_diagnostics_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_diagnostics_operations.py new file mode 100644 index 0000000000000..a5c4d407195b7 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_diagnostics_operations.py @@ -0,0 +1,598 @@ +# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_detectors_request( + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectors", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_detector_request( + resource_group_name: str, container_app_name: str, detector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectors/{detectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "detectorName": _SERIALIZER.url("detector_name", detector_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_revisions_request( + resource_group_name: str, + container_app_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/revisionsApi/revisions/", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_revision_request( + resource_group_name: str, container_app_name: str, revision_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/revisionsApi/revisions/{revisionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "revisionName": _SERIALIZER.url("revision_name", revision_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_root_request( + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/rootApi/", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerAppsDiagnosticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`container_apps_diagnostics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_detectors( + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> Iterable["_models.Diagnostics"]: + """Get the list of diagnostics for a given Container App. + + Get the list of diagnostics for a given Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App for which detector info is needed. + Required. + :type container_app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Diagnostics or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.Diagnostics] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticsCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_detectors_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_detectors.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DiagnosticsCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_detectors.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectors"} # type: ignore + + @distributed_trace + def get_detector( + self, resource_group_name: str, container_app_name: str, detector_name: str, **kwargs: Any + ) -> _models.Diagnostics: + """Get a diagnostics result of a Container App. + + Get a diagnostics result of a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param detector_name: Name of the Container App Detector. Required. + :type detector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Diagnostics or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Diagnostics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Diagnostics] + + request = build_get_detector_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + detector_name=detector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_detector.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Diagnostics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_detector.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectors/{detectorName}"} # type: ignore + + @distributed_trace + def list_revisions( + self, resource_group_name: str, container_app_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Revision"]: + """Get the Revisions for a given Container App. + + Get the Revisions for a given Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App for which Revisions are needed. Required. + :type container_app_name: str + :param filter: The filter to apply on the operation. Default value is None. + :type filter: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Revision or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.Revision] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RevisionCollection] + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_revisions_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + filter=filter, + api_version=api_version, + template_url=self.list_revisions.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + else: + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RevisionCollection", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = 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.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_revisions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/revisionsApi/revisions/"} # type: ignore + + @distributed_trace + def get_revision( + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any + ) -> _models.Revision: + """Get a revision of a Container App. + + Get a revision of a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param revision_name: Name of the Container App Revision. Required. + :type revision_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Revision or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Revision + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Revision] + + request = build_get_revision_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + revision_name=revision_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_revision.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Revision", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/revisionsApi/revisions/{revisionName}"} # type: ignore + + @distributed_trace + def get_root(self, resource_group_name: str, container_app_name: str, **kwargs: Any) -> _models.ContainerApp: + """Get the properties of a Container App. + + Get the properties of a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContainerApp or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ContainerApp + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] + + request = build_get_root_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_root.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerApp", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/detectorProperties/rootApi/"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_operations.py index 23362edb8dd9f..a04bf0466c8df 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_operations.py @@ -6,394 +6,401 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - accept = "application/json" +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.App/containerApps") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_create_or_update_request( + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - **kwargs: Any +def build_delete_request( + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_update_request( + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_custom_host_name_analysis_request( - subscription_id: str, resource_group_name: str, container_app_name: str, + subscription_id: str, *, custom_hostname: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listCustomHostNameAnalysis") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listCustomHostNameAnalysis", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if custom_hostname is not None: - _query_parameters['customHostname'] = _SERIALIZER.query("custom_hostname", custom_hostname, 'str') - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["customHostname"] = _SERIALIZER.query("custom_hostname", custom_hostname, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_secrets_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listSecrets", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_auth_token_request( + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listSecrets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/getAuthtoken", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ContainerAppsOperations(object): - """ContainerAppsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerAppsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`container_apps` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ContainerAppCollection"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ContainerApp"]: """Get the Container Apps in a given subscription. Get the Container Apps in a given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContainerAppCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ContainerAppCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ContainerApp or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerAppCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerAppCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -407,10 +414,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -421,59 +426,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.App/containerApps"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/containerApps"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ContainerAppCollection"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ContainerApp"]: """Get the Container Apps in a given resource group. Get the Container Apps in a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ContainerAppCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ContainerAppCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ContainerApp or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerAppCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerAppCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -487,10 +493,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -501,56 +505,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> "_models.ContainerApp": + def get(self, resource_group_name: str, container_app_name: str, **kwargs: Any) -> _models.ContainerApp: """Get the properties of a Container App. Get the properties of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ContainerApp, or the result of cls(response) + :return: ContainerApp or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ContainerApp - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerApp"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -558,89 +562,183 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any - ) -> "_models.ContainerApp": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerApp"] + ) -> _models.ContainerApp: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(container_app_envelope, 'ContainerApp') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container_app_envelope, (IO, bytes)): + _content = container_app_envelope + else: + _json = self._serialize.body(container_app_envelope, "ContainerApp") + + request = build_create_or_update_request( resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: _models.ContainerApp, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ContainerApp]: + """Create or update a Container App. + + Create or update a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties used to create a container app. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ContainerApp or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ContainerApp]: + """Create or update a Container App. + Create or update a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties used to create a container app. Required. + :type container_app_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ContainerApp or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ContainerApp] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any - ) -> LROPoller["_models.ContainerApp"]: + ) -> LROPoller[_models.ContainerApp]: """Create or update a Container App. - Description for Create or update a Container App. + Create or update a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param container_app_envelope: Properties used to create a container app. - :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :param container_app_envelope: Properties used to create a container app. Is either a model + type or a IO type. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -652,107 +750,109 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either ContainerApp or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ContainerApp] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ContainerApp"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerApp] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, container_app_envelope=container_app_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ContainerApp', pipeline_response) + deserialized = self._deserialize("ContainerApp", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, container_app_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a Container App. - Description for Delete a Container App. + Delete a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -764,98 +864,190 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore def _update_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(container_app_envelope, 'ContainerApp') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(container_app_envelope, (IO, bytes)): + _content = container_app_envelope + else: + _json = self._serialize.body(container_app_envelope, "ContainerApp") + + request = build_update_request( resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: _models.ContainerApp, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update properties of a Container App. + + Patches a Container App using JSON Merge Patch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties of a Container App that need to be updated. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + container_app_name: str, + container_app_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update properties of a Container App. + + Patches a Container App using JSON Merge Patch. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param container_app_envelope: Properties of a Container App that need to be updated. Required. + :type container_app_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def begin_update( # pylint: disable=inconsistent-return-statements + def begin_update( self, resource_group_name: str, container_app_name: str, - container_app_envelope: "_models.ContainerApp", + container_app_envelope: Union[_models.ContainerApp, IO], **kwargs: Any ) -> LROPoller[None]: """Update properties of a Container App. @@ -863,11 +1055,16 @@ def begin_update( # pylint: disable=inconsistent-return-statements Patches a Container App using JSON Merge Patch. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param container_app_envelope: Properties of a Container App that need to be updated. - :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp + :param container_app_envelope: Properties of a Container App that need to be updated. Is either + a model type or a IO type. Required. + :type container_app_envelope: ~azure.mgmt.appcontainers.models.ContainerApp or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -878,96 +1075,103 @@ def begin_update( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, container_app_envelope=container_app_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}"} # type: ignore @distributed_trace def list_custom_host_name_analysis( - self, - resource_group_name: str, - container_app_name: str, - custom_hostname: Optional[str] = None, - **kwargs: Any - ) -> "_models.CustomHostnameAnalysisResult": + self, resource_group_name: str, container_app_name: str, custom_hostname: Optional[str] = None, **kwargs: Any + ) -> _models.CustomHostnameAnalysisResult: """Analyzes a custom hostname for a Container App. Analyzes a custom hostname for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :param custom_hostname: Custom hostname. Default value is None. :type custom_hostname: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomHostnameAnalysisResult, or the result of cls(response) + :return: CustomHostnameAnalysisResult or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.CustomHostnameAnalysisResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomHostnameAnalysisResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomHostnameAnalysisResult] - request = build_list_custom_host_name_analysis_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, custom_hostname=custom_hostname, - template_url=self.list_custom_host_name_analysis.metadata['url'], + api_version=api_version, + template_url=self.list_custom_host_name_analysis.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -975,60 +1179,63 @@ def list_custom_host_name_analysis( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomHostnameAnalysisResult', pipeline_response) + deserialized = self._deserialize("CustomHostnameAnalysisResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_custom_host_name_analysis.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listCustomHostNameAnalysis"} # type: ignore - + list_custom_host_name_analysis.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listCustomHostNameAnalysis"} # type: ignore @distributed_trace def list_secrets( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> "_models.SecretsCollection": + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> _models.SecretsCollection: """List secrets for a container app. List secrets for a container app. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SecretsCollection, or the result of cls(response) + :return: SecretsCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.SecretsCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SecretsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecretsCollection] - request = build_list_secrets_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_secrets.metadata['url'], + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1036,12 +1243,75 @@ def list_secrets( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SecretsCollection', pipeline_response) + deserialized = self._deserialize("SecretsCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listSecrets"} # type: ignore + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/listSecrets"} # type: ignore + + @distributed_trace + def get_auth_token( + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> _models.ContainerAppAuthToken: + """Get auth token for a container app. + + Get auth token for a container app. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ContainerAppAuthToken or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ContainerAppAuthToken + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ContainerAppAuthToken] + + request = build_get_auth_token_request( + resource_group_name=resource_group_name, + container_app_name=container_app_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_auth_token.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ContainerAppAuthToken", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + get_auth_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/getAuthtoken"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revision_replicas_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revision_replicas_operations.py index ea265a1598bf1..db1709a516e8a 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revision_replicas_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revision_replicas_operations.py @@ -8,174 +8,179 @@ # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_replica_request( - subscription_id: str, resource_group_name: str, container_app_name: str, revision_name: str, replica_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas/{replicaName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas/{replicaName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "revisionName": _SERIALIZER.url("revision_name", revision_name, 'str'), - "replicaName": _SERIALIZER.url("replica_name", replica_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "revisionName": _SERIALIZER.url("revision_name", revision_name, "str"), + "replicaName": _SERIALIZER.url("replica_name", replica_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_replicas_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, revision_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "revisionName": _SERIALIZER.url("revision_name", revision_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "revisionName": _SERIALIZER.url("revision_name", revision_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ContainerAppsRevisionReplicasOperations(object): - """ContainerAppsRevisionReplicasOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerAppsRevisionReplicasOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`container_apps_revision_replicas` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get_replica( - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - replica_name: str, - **kwargs: Any - ) -> "_models.Replica": + self, resource_group_name: str, container_app_name: str, revision_name: str, replica_name: str, **kwargs: Any + ) -> _models.Replica: """Get a replica for a Container App Revision. Get a replica for a Container App Revision. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str - :param replica_name: Name of the Container App Revision Replica. + :param replica_name: Name of the Container App Revision Replica. Required. :type replica_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Replica, or the result of cls(response) + :return: Replica or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Replica - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Replica"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Replica] - request = build_get_replica_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, replica_name=replica_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_replica.metadata['url'], + template_url=self.get_replica.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -183,64 +188,66 @@ def get_replica( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Replica', pipeline_response) + deserialized = self._deserialize("Replica", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_replica.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas/{replicaName}"} # type: ignore - + get_replica.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas/{replicaName}"} # type: ignore @distributed_trace def list_replicas( - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any - ) -> "_models.ReplicaCollection": + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any + ) -> _models.ReplicaCollection: """List replicas for a Container App Revision. List replicas for a Container App Revision. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ReplicaCollection, or the result of cls(response) + :return: ReplicaCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ReplicaCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ReplicaCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ReplicaCollection] - request = build_list_replicas_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_replicas.metadata['url'], + template_url=self.list_replicas.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -248,12 +255,11 @@ def list_replicas( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ReplicaCollection', pipeline_response) + deserialized = self._deserialize("ReplicaCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_replicas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas"} # type: ignore - + list_replicas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/replicas"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revisions_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revisions_operations.py index 680c301f55cd4..f63b88b0b0a02 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revisions_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_revisions_operations.py @@ -7,294 +7,288 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_revisions_request( - subscription_id: str, resource_group_name: str, container_app_name: str, + subscription_id: str, *, filter: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if filter is not None: - _query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_revision_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, revision_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "revisionName": _SERIALIZER.url("revision_name", revision_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "revisionName": _SERIALIZER.url("revision_name", revision_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_activate_revision_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, revision_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/activate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/activate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "revisionName": _SERIALIZER.url("revision_name", revision_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "revisionName": _SERIALIZER.url("revision_name", revision_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_deactivate_revision_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, revision_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/deactivate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/deactivate", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "revisionName": _SERIALIZER.url("revision_name", revision_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "revisionName": _SERIALIZER.url("revision_name", revision_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_restart_revision_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, revision_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/restart") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/restart", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "revisionName": _SERIALIZER.url("revision_name", revision_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "revisionName": _SERIALIZER.url("revision_name", revision_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ContainerAppsRevisionsOperations(object): - """ContainerAppsRevisionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerAppsRevisionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`container_apps_revisions` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_revisions( - self, - resource_group_name: str, - container_app_name: str, - filter: Optional[str] = None, - **kwargs: Any - ) -> Iterable["_models.RevisionCollection"]: + self, resource_group_name: str, container_app_name: str, filter: Optional[str] = None, **kwargs: Any + ) -> Iterable["_models.Revision"]: """Get the Revisions for a given Container App. Get the Revisions for a given Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App for which Revisions are needed. + :param container_app_name: Name of the Container App for which Revisions are needed. Required. :type container_app_name: str :param filter: The filter to apply on the operation. Default value is None. :type filter: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either RevisionCollection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.RevisionCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Revision or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.Revision] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.RevisionCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.RevisionCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_revisions_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, - api_version=api_version, + subscription_id=self._config.subscription_id, filter=filter, - template_url=self.list_revisions.metadata['url'], + api_version=api_version, + template_url=self.list_revisions.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_revisions_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - container_app_name=container_app_name, - api_version=api_version, - filter=filter, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -308,10 +302,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -322,60 +314,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_revisions.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions"} # type: ignore + list_revisions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions"} # type: ignore @distributed_trace def get_revision( - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any - ) -> "_models.Revision": + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any + ) -> _models.Revision: """Get a revision of a Container App. Get a revision of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Revision, or the result of cls(response) + :return: Revision or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.Revision - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.Revision"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Revision] - request = build_get_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_revision.metadata['url'], + template_url=self.get_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -383,64 +376,66 @@ def get_revision( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Revision', pipeline_response) + deserialized = self._deserialize("Revision", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}"} # type: ignore - + get_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}"} # type: ignore @distributed_trace def activate_revision( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any ) -> None: """Activates a revision for a Container App. Activates a revision for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_activate_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.activate_revision.metadata['url'], + template_url=self.activate_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -451,57 +446,59 @@ def activate_revision( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - activate_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/activate"} # type: ignore - + activate_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/activate"} # type: ignore @distributed_trace def deactivate_revision( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any ) -> None: """Deactivates a revision for a Container App. Deactivates a revision for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_deactivate_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.deactivate_revision.metadata['url'], + template_url=self.deactivate_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -512,57 +509,59 @@ def deactivate_revision( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - deactivate_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/deactivate"} # type: ignore - + deactivate_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/deactivate"} # type: ignore @distributed_trace def restart_revision( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - revision_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, revision_name: str, **kwargs: Any ) -> None: """Restarts a revision for a Container App. Restarts a revision for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param revision_name: Name of the Container App Revision. + :param revision_name: Name of the Container App Revision. Required. :type revision_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_restart_revision_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, revision_name=revision_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.restart_revision.metadata['url'], + template_url=self.restart_revision.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -573,5 +572,4 @@ def restart_revision( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restart_revision.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/restart"} # type: ignore - + restart_revision.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/revisions/{revisionName}/restart"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_source_controls_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_source_controls_operations.py index 8e54fbb9d51b3..77ef5a7ad2ca4 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_source_controls_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_container_apps_source_controls_operations.py @@ -6,260 +6,250 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_container_app_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any + resource_group_name: str, container_app_name: str, source_control_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, container_app_name: str, source_control_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, container_app_name: str, source_control_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, 'str'), - "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "containerAppName": _SERIALIZER.url("container_app_name", container_app_name, "str"), + "sourceControlName": _SERIALIZER.url("source_control_name", source_control_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ContainerAppsSourceControlsOperations(object): - """ContainerAppsSourceControlsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ContainerAppsSourceControlsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`container_apps_source_controls` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list_by_container_app( - self, - resource_group_name: str, - container_app_name: str, - **kwargs: Any - ) -> Iterable["_models.SourceControlCollection"]: + self, resource_group_name: str, container_app_name: str, **kwargs: Any + ) -> Iterable["_models.SourceControl"]: """Get the Container App SourceControls in a given resource group. Get the Container App SourceControls in a given resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SourceControlCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.SourceControlCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SourceControl or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.SourceControl] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControlCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControlCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_container_app.metadata['url'], + template_url=self.list_by_container_app.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_container_app_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - container_app_name=container_app_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -273,10 +263,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -287,60 +275,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_container_app.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols"} # type: ignore + list_by_container_app.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any - ) -> "_models.SourceControl": + self, resource_group_name: str, container_app_name: str, source_control_name: str, **kwargs: Any + ) -> _models.SourceControl: """Get a SourceControl of a Container App. Get a SourceControl of a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param source_control_name: Name of the Container App SourceControl. + :param source_control_name: Name of the Container App SourceControl. Required. :type source_control_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SourceControl, or the result of cls(response) + :return: SourceControl or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.SourceControl - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControl] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -348,94 +337,114 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SourceControl', pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, container_app_name: str, source_control_name: str, - source_control_envelope: "_models.SourceControl", + source_control_envelope: Union[_models.SourceControl, IO], **kwargs: Any - ) -> "_models.SourceControl": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] + ) -> _models.SourceControl: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(source_control_envelope, 'SourceControl') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControl] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(source_control_envelope, (IO, bytes)): + _content = source_control_envelope + else: + _json = self._serialize.body(source_control_envelope, "SourceControl") + + request = build_create_or_update_request( resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response - if response.status_code not in [200, 202]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SourceControl', pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response) - if response.status_code == 202: - deserialized = self._deserialize('SourceControl', pipeline_response) + if response.status_code == 201: + deserialized = self._deserialize("SourceControl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, container_app_name: str, source_control_name: str, - source_control_envelope: "_models.SourceControl", + source_control_envelope: _models.SourceControl, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.SourceControl"]: + ) -> LROPoller[_models.SourceControl]: """Create or update the SourceControl for a Container App. - Description for Create or update the SourceControl for a Container App. + Create or update the SourceControl for a Container App. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param source_control_name: Name of the Container App SourceControl. + :param source_control_name: Name of the Container App SourceControl. Required. :type source_control_name: str :param source_control_envelope: Properties used to create a Container App SourceControl. + Required. :type source_control_envelope: ~azure.mgmt.appcontainers.models.SourceControl + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -447,113 +456,197 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either SourceControl or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.SourceControl] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SourceControl"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + source_control_name: str, + source_control_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SourceControl]: + """Create or update the SourceControl for a Container App. + + Create or update the SourceControl for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param source_control_name: Name of the Container App SourceControl. Required. + :type source_control_name: str + :param source_control_envelope: Properties used to create a Container App SourceControl. + Required. + :type source_control_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SourceControl or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.SourceControl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + container_app_name: str, + source_control_name: str, + source_control_envelope: Union[_models.SourceControl, IO], + **kwargs: Any + ) -> LROPoller[_models.SourceControl]: + """Create or update the SourceControl for a Container App. + + Create or update the SourceControl for a Container App. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param container_app_name: Name of the Container App. Required. + :type container_app_name: str + :param source_control_name: Name of the Container App SourceControl. Required. + :type source_control_name: str + :param source_control_envelope: Properties used to create a Container App SourceControl. Is + either a model type or a IO type. Required. + :type source_control_envelope: ~azure.mgmt.appcontainers.models.SourceControl or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either SourceControl or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.SourceControl] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SourceControl] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, source_control_envelope=source_control_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SourceControl', pipeline_response) + deserialized = self._deserialize("SourceControl", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any + self, resource_group_name: str, container_app_name: str, source_control_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - container_app_name: str, - source_control_name: str, - **kwargs: Any + def begin_delete( + self, resource_group_name: str, container_app_name: str, source_control_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete a Container App SourceControl. - Description for Delete a Container App SourceControl. + Delete a Container App SourceControl. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param container_app_name: Name of the Container App. + :param container_app_name: Name of the Container App. Required. :type container_app_name: str - :param source_control_name: Name of the Container App SourceControl. + :param source_control_name: Name of the Container App SourceControl. Required. :type source_control_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -565,42 +658,46 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, container_app_name=container_app_name, source_control_name=source_control_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/containerApps/{containerAppName}/sourcecontrols/{sourceControlName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_dapr_components_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_dapr_components_operations.py index 3e466039fbfb4..675f149988b3c 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_dapr_components_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_dapr_components_operations.py @@ -6,296 +6,280 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, component_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "componentName": _SERIALIZER.url("component_name", component_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - component_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, environment_name: str, component_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "componentName": _SERIALIZER.url("component_name", component_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, component_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "componentName": _SERIALIZER.url("component_name", component_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_secrets_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, component_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}/listSecrets") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}/listSecrets", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "componentName": _SERIALIZER.url("component_name", component_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "componentName": _SERIALIZER.url("component_name", component_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class DaprComponentsOperations(object): - """DaprComponentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DaprComponentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`dapr_components` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> Iterable["_models.DaprComponentsCollection"]: + def list(self, resource_group_name: str, environment_name: str, **kwargs: Any) -> Iterable["_models.DaprComponent"]: """Get the Dapr Components for a managed environment. Get the Dapr Components for a managed environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DaprComponentsCollection or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.DaprComponentsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DaprComponent or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.DaprComponent] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponentsCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprComponentsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - environment_name=environment_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -309,10 +293,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -323,60 +305,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any - ) -> "_models.DaprComponent": + self, resource_group_name: str, environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprComponent: """Get a dapr component. Get a dapr component. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DaprComponent, or the result of cls(response) + :return: DaprComponent or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.DaprComponent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprComponent"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -384,15 +367,80 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DaprComponent', pipeline_response) + deserialized = self._deserialize("DaprComponent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + environment_name: str, + component_name: str, + dapr_component_envelope: _models.DaprComponent, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a Managed Environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + environment_name: str, + component_name: str, + dapr_component_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.DaprComponent: + """Creates or updates a Dapr Component. + + Creates or updates a Dapr Component in a Managed Environment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param component_name: Name of the Dapr Component. Required. + :type component_name: str + :param dapr_component_envelope: Configuration details of the Dapr Component. Required. + :type dapr_component_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DaprComponent or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DaprComponent + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -400,55 +448,74 @@ def create_or_update( resource_group_name: str, environment_name: str, component_name: str, - dapr_component_envelope: "_models.DaprComponent", + dapr_component_envelope: Union[_models.DaprComponent, IO], **kwargs: Any - ) -> "_models.DaprComponent": + ) -> _models.DaprComponent: """Creates or updates a Dapr Component. Creates or updates a Dapr Component in a Managed Environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str - :param dapr_component_envelope: Configuration details of the Dapr Component. - :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent + :param dapr_component_envelope: Configuration details of the Dapr Component. Is either a model + type or a IO type. Required. + :type dapr_component_envelope: ~azure.mgmt.appcontainers.models.DaprComponent or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DaprComponent, or the result of cls(response) + :return: DaprComponent or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.DaprComponent - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprComponent"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(dapr_component_envelope, 'DaprComponent') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprComponent] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(dapr_component_envelope, (IO, bytes)): + _content = dapr_component_envelope + else: + _json = self._serialize.body(dapr_component_envelope, "DaprComponent") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -456,64 +523,66 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DaprComponent', pipeline_response) + deserialized = self._deserialize("DaprComponent", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, component_name: str, **kwargs: Any ) -> None: """Delete a Dapr Component. Delete a Dapr Component from a Managed Environment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -524,57 +593,59 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}"} # type: ignore @distributed_trace def list_secrets( - self, - resource_group_name: str, - environment_name: str, - component_name: str, - **kwargs: Any - ) -> "_models.DaprSecretsCollection": + self, resource_group_name: str, environment_name: str, component_name: str, **kwargs: Any + ) -> _models.DaprSecretsCollection: """List secrets for a dapr component. List secrets for a dapr component. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param component_name: Name of the Dapr Component. + :param component_name: Name of the Dapr Component. Required. :type component_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DaprSecretsCollection, or the result of cls(response) + :return: DaprSecretsCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.DaprSecretsCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.DaprSecretsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DaprSecretsCollection] - request = build_list_secrets_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, component_name=component_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_secrets.metadata['url'], + template_url=self.list_secrets.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -582,12 +653,11 @@ def list_secrets( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DaprSecretsCollection', pipeline_response) + deserialized = self._deserialize("DaprSecretsCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_secrets.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}/listSecrets"} # type: ignore - + list_secrets.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/daprComponents/{componentName}/listSecrets"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environment_diagnostics_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environment_diagnostics_operations.py new file mode 100644 index 0000000000000..6f005941581f4 --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environment_diagnostics_operations.py @@ -0,0 +1,252 @@ +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_detectors_request( + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectors", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_detector_request( + resource_group_name: str, environment_name: str, detector_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectors/{detectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "detectorName": _SERIALIZER.url("detector_name", detector_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ManagedEnvironmentDiagnosticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`managed_environment_diagnostics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_detectors( + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> _models.DiagnosticsCollection: + """Get the list of diagnostics for a given Managed Environment. + + Get the list of diagnostics for a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DiagnosticsCollection or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.DiagnosticsCollection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiagnosticsCollection] + + request = build_list_detectors_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_detectors.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DiagnosticsCollection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_detectors.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectors"} # type: ignore + + @distributed_trace + def get_detector( + self, resource_group_name: str, environment_name: str, detector_name: str, **kwargs: Any + ) -> _models.Diagnostics: + """Get the diagnostics data for a given Managed Environment. + + Get the diagnostics data for a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param detector_name: Name of the Managed Environment detector. Required. + :type detector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Diagnostics or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.Diagnostics + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.Diagnostics] + + request = build_get_detector_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + detector_name=detector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_detector.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Diagnostics", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_detector.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectors/{detectorName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_diagnostics_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_diagnostics_operations.py new file mode 100644 index 0000000000000..ff20ef06339af --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_diagnostics_operations.py @@ -0,0 +1,149 @@ +# 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 typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_root_request( + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectorProperties/rootApi/", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class ManagedEnvironmentsDiagnosticsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`managed_environments_diagnostics` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get_root(self, resource_group_name: str, environment_name: str, **kwargs: Any) -> _models.ManagedEnvironment: + """Get the properties of a Managed Environment. + + Get the properties of a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedEnvironment or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] + + request = build_get_root_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_root.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_root.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/detectorProperties/rootApi/"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_operations.py index ff89f77a69298..97b1a824f3a8c 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_operations.py @@ -6,319 +6,328 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - accept = "application/json" +def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.App/managedEnvironments") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _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 = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - environment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - environment_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - environment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class ManagedEnvironmentsOperations(object): - """ManagedEnvironmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_auth_token_request( + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/getAuthtoken", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class ManagedEnvironmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`managed_environments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ManagedEnvironmentsCollection"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ManagedEnvironment"]: """Get all Environments for a subscription. Get all Managed Environments for a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedEnvironmentsCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironmentsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ManagedEnvironment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentsCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -332,10 +341,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -346,60 +353,60 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.App/managedEnvironments"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.App/managedEnvironments"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ManagedEnvironmentsCollection"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.ManagedEnvironment"]: """Get all the Environments in a resource group. Get all the Managed Environments in a resource group. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ManagedEnvironmentsCollection or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironmentsCollection] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ManagedEnvironment or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentsCollection] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentsCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata['url'], + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -413,10 +420,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -427,56 +432,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> "_models.ManagedEnvironment": + def get(self, resource_group_name: str, environment_name: str, **kwargs: Any) -> _models.ManagedEnvironment: """Get the properties of a Managed Environment. Get the properties of a Managed Environment used to host container apps. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironment, or the result of cls(response) + :return: ManagedEnvironment or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironment - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironment"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -484,89 +489,183 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any - ) -> "_models.ManagedEnvironment": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironment"] + ) -> _models.ManagedEnvironment: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(environment_envelope, 'ManagedEnvironment') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(environment_envelope, (IO, bytes)): + _content = environment_envelope + else: + _json = self._serialize.body(environment_envelope, "ManagedEnvironment") + + request = build_create_or_update_request( resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: _models.ManagedEnvironment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedEnvironment]: + """Creates or updates a Managed Environment. + + Creates or updates a Managed Environment used to host container apps. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedEnvironment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ManagedEnvironment]: + """Creates or updates a Managed Environment. + + Creates or updates a Managed Environment used to host container apps. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ManagedEnvironment or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ManagedEnvironment] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any - ) -> LROPoller["_models.ManagedEnvironment"]: + ) -> LROPoller[_models.ManagedEnvironment]: """Creates or updates a Managed Environment. Creates or updates a Managed Environment used to host container apps. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param environment_envelope: Configuration details of the Environment. - :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :param environment_envelope: Configuration details of the Environment. Is either a model type + or a IO type. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -578,107 +677,109 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either ManagedEnvironment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.appcontainers.models.ManagedEnvironment] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironment"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironment] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, environment_name=environment_name, environment_envelope=environment_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ManagedEnvironment', pipeline_response) + deserialized = self._deserialize("ManagedEnvironment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore @distributed_trace - def begin_delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, environment_name: str, **kwargs: Any) -> LROPoller[None]: """Delete a Managed Environment. Delete a Managed Environment if it does not have any container apps. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. @@ -690,98 +791,190 @@ def begin_delete( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, environment_name=environment_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore def _update_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(environment_envelope, 'ManagedEnvironment') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(environment_envelope, (IO, bytes)): + _content = environment_envelope + else: + _json = self._serialize.body(environment_envelope, "ManagedEnvironment") + + request = build_update_request( resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _update_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: _models.ManagedEnvironment, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update Managed Environment's properties. + + Patches a Managed Environment using JSON Merge Patch. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + environment_name: str, + environment_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[None]: + """Update Managed Environment's properties. + + Patches a Managed Environment using JSON Merge Patch. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param environment_envelope: Configuration details of the Environment. Required. + :type environment_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def begin_update( # pylint: disable=inconsistent-return-statements + def begin_update( self, resource_group_name: str, environment_name: str, - environment_envelope: "_models.ManagedEnvironment", + environment_envelope: Union[_models.ManagedEnvironment, IO], **kwargs: Any ) -> LROPoller[None]: """Update Managed Environment's properties. @@ -789,11 +982,16 @@ def begin_update( # pylint: disable=inconsistent-return-statements Patches a Managed Environment using JSON Merge Patch. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param environment_envelope: Configuration details of the Environment. - :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment + :param environment_envelope: Configuration details of the Environment. Is either a model type + or a IO type. Required. + :type environment_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironment or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this @@ -804,44 +1002,112 @@ def begin_update( # pylint: disable=inconsistent-return-statements Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, environment_name=environment_name, environment_envelope=environment_envelope, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}"} # type: ignore + + @distributed_trace + def get_auth_token( + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> _models.EnvironmentAuthToken: + """Get auth token for a managed environment. + + Checks if resource name is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EnvironmentAuthToken or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.EnvironmentAuthToken + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + 404: lambda response: ResourceNotFoundError(response=response, error_format=ARMErrorFormat), + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnvironmentAuthToken] + + request = build_get_auth_token_request( + resource_group_name=resource_group_name, + environment_name=environment_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_auth_token.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EnvironmentAuthToken", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_auth_token.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/getAuthtoken"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_storages_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_storages_operations.py index 89642445aa0b0..ead40f6107008 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_storages_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_managed_environments_storages_operations.py @@ -6,249 +6,239 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - storage_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "storageName": _SERIALIZER.url("storage_name", storage_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - storage_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, environment_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "storageName": _SERIALIZER.url("storage_name", storage_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - environment_name: str, - storage_name: str, - **kwargs: Any + resource_group_name: str, environment_name: str, storage_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), - "storageName": _SERIALIZER.url("storage_name", storage_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), + "storageName": _SERIALIZER.url("storage_name", storage_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class ManagedEnvironmentsStoragesOperations(object): - """ManagedEnvironmentsStoragesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ManagedEnvironmentsStoragesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`managed_environments_storages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - environment_name: str, - **kwargs: Any - ) -> "_models.ManagedEnvironmentStoragesCollection": + self, resource_group_name: str, environment_name: str, **kwargs: Any + ) -> _models.ManagedEnvironmentStoragesCollection: """Get all storages for a managedEnvironment. Get all storages for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironmentStoragesCollection, or the result of cls(response) + :return: ManagedEnvironmentStoragesCollection or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStoragesCollection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentStoragesCollection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentStoragesCollection] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -256,64 +246,66 @@ def list( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironmentStoragesCollection', pipeline_response) + deserialized = self._deserialize("ManagedEnvironmentStoragesCollection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - environment_name: str, - storage_name: str, - **kwargs: Any - ) -> "_models.ManagedEnvironmentStorage": + self, resource_group_name: str, environment_name: str, storage_name: str, **kwargs: Any + ) -> _models.ManagedEnvironmentStorage: """Get storage for a managedEnvironment. Get storage for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param storage_name: Name of the storage. + :param storage_name: Name of the storage. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironmentStorage, or the result of cls(response) + :return: ManagedEnvironmentStorage or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentStorage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentStorage] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, storage_name=storage_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -321,15 +313,80 @@ def get( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironmentStorage', pipeline_response) + deserialized = self._deserialize("ManagedEnvironmentStorage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + environment_name: str, + storage_name: str, + storage_envelope: _models.ManagedEnvironmentStorage, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedEnvironmentStorage: + """Create or update storage for a managedEnvironment. + + Create or update storage for a managedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + environment_name: str, + storage_name: str, + storage_envelope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagedEnvironmentStorage: + """Create or update storage for a managedEnvironment. + + Create or update storage for a managedEnvironment. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Environment. Required. + :type environment_name: str + :param storage_name: Name of the storage. Required. + :type storage_name: str + :param storage_envelope: Configuration details of storage. Required. + :type storage_envelope: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagedEnvironmentStorage or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -337,55 +394,74 @@ def create_or_update( resource_group_name: str, environment_name: str, storage_name: str, - storage_envelope: "_models.ManagedEnvironmentStorage", + storage_envelope: Union[_models.ManagedEnvironmentStorage, IO], **kwargs: Any - ) -> "_models.ManagedEnvironmentStorage": + ) -> _models.ManagedEnvironmentStorage: """Create or update storage for a managedEnvironment. Create or update storage for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param storage_name: Name of the storage. + :param storage_name: Name of the storage. Required. :type storage_name: str - :param storage_envelope: Configuration details of storage. - :type storage_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage + :param storage_envelope: Configuration details of storage. Is either a model type or a IO type. + Required. + :type storage_envelope: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagedEnvironmentStorage, or the result of cls(response) + :return: ManagedEnvironmentStorage or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.ManagedEnvironmentStorage - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ManagedEnvironmentStorage"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(storage_envelope, 'ManagedEnvironmentStorage') + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagedEnvironmentStorage] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(storage_envelope, (IO, bytes)): + _content = storage_envelope + else: + _json = self._serialize.body(storage_envelope, "ManagedEnvironmentStorage") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, storage_name=storage_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -393,64 +469,66 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagedEnvironmentStorage', pipeline_response) + deserialized = self._deserialize("ManagedEnvironmentStorage", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - environment_name: str, - storage_name: str, - **kwargs: Any + self, resource_group_name: str, environment_name: str, storage_name: str, **kwargs: Any ) -> None: """Delete storage for a managedEnvironment. Delete storage for a managedEnvironment. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Environment. + :param environment_name: Name of the Environment. Required. :type environment_name: str - :param storage_name: Name of the storage. + :param storage_name: Name of the storage. Required. :type storage_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, storage_name=storage_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,5 +539,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/storages/{storageName}"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_namespaces_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_namespaces_operations.py index 59f158efe0d75..d555f94dcc04b 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_namespaces_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_namespaces_operations.py @@ -6,143 +6,221 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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, - resource_group_name: str, - environment_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, environment_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/checkNameAvailability") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "environmentName": _SERIALIZER.url("environment_name", environment_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "environmentName": _SERIALIZER.url("environment_name", environment_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - _header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_query_parameters, - headers=_header_parameters, - json=json, - content=content, - **kwargs - ) - -class NamespacesOperations(object): - """NamespacesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class NamespacesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`namespaces` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( self, resource_group_name: str, environment_name: str, - check_name_availability_request: "_models.CheckNameAvailabilityRequest", + check_name_availability_request: _models.CheckNameAvailabilityRequest, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + ) -> _models.CheckNameAvailabilityResponse: """Checks the resource name availability. Checks if resource name is available. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param environment_name: Name of the Managed Environment. + :param environment_name: Name of the Managed Environment. Required. :type environment_name: str - :param check_name_availability_request: The check name availability request. + :param check_name_availability_request: The check name availability request. Required. :type check_name_availability_request: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, + resource_group_name: str, + environment_name: str, + check_name_availability_request: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource name availability. + + Checks if resource name is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param check_name_availability_request: The check name availability request. Required. + :type check_name_availability_request: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CheckNameAvailabilityResponse, or the result of cls(response) + :return: CheckNameAvailabilityResponse or the result of cls(response) :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, + resource_group_name: str, + environment_name: str, + check_name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], + **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the resource name availability. + + Checks if resource name is available. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param environment_name: Name of the Managed Environment. Required. + :type environment_name: str + :param check_name_availability_request: The check name availability request. Is either a model + type or a IO type. Required. + :type check_name_availability_request: + ~azure.mgmt.appcontainers.models.CheckNameAvailabilityRequest or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.appcontainers.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] - _json = self._serialize.body(check_name_availability_request, 'CheckNameAvailabilityRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(check_name_availability_request, (IO, bytes)): + _content = check_name_availability_request + else: + _json = self._serialize.body(check_name_availability_request, "CheckNameAvailabilityRequest") request = build_check_name_availability_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, environment_name=environment_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -150,12 +228,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.DefaultErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.App/managedEnvironments/{environmentName}/checkNameAvailability"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_operations.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_operations.py index d134b642c4d1e..369b6b60807f5 100644 --- a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_operations.py +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_operations.py @@ -7,109 +7,116 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any, Callable, Dict, Iterable, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from urllib.parse import parse_qs, urljoin, urlparse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = kwargs.pop('api_version', "2022-03-01") # type: str - accept = "application/json" +def build_list_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-06-01-preview")) # type: str + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.App/operations") # Construct parameters - _query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - _query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - _header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_query_parameters, - headers=_header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.appcontainers.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.appcontainers.ContainerAppsAPIClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.AvailableOperations"]: + def list(self, **kwargs: Any) -> Iterable["_models.OperationDetail"]: """Lists all of the available RP operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailableOperations or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.AvailableOperations] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either OperationDetail or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.appcontainers.models.OperationDetail] + :raises ~azure.core.exceptions.HttpResponseError: """ - api_version = kwargs.pop('api_version', "2022-03-01") # type: str + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) # type: str + cls = kwargs.pop("cls", None) # type: ClsType[_models.AvailableOperations] - cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailableOperations"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - ) + # make call to next link with the client's api-version + _parsed_next_link = urlparse(next_link) + _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest("GET", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -123,10 +130,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -137,8 +142,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.App/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.App/operations"} # type: ignore diff --git a/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_patch.py b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_patch.py new file mode 100644 index 0000000000000..f7dd32510333d --- /dev/null +++ b/sdk/appcontainers/azure-mgmt-appcontainers/azure/mgmt/appcontainers/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """